blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
410
content_id
stringlengths
40
40
detected_licenses
sequencelengths
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
sequencelengths
1
1
author_id
stringlengths
0
313
2ca16296e7eb7d28f50d1f1ccc1ce49d9312ef8a
b509baa681862a9191dc0eb0676a76cb83679817
/framework/config/src/main/java/com/minlia/cloud/framework/config/Constants.java
bbbddfc055a5903da2dc947f5cb0cd84aa7f944e
[ "Apache-2.0" ]
permissive
minlia/cloud
bbfd5af1484cedaa5adebf11c14fea428efeb0bc
8e6969e743216fc17eb93dd3fdf392d8443cd7bb
refs/heads/master
2021-01-10T06:42:49.524349
2017-08-21T15:13:28
2017-08-21T15:13:28
46,135,585
11
8
null
null
null
null
UTF-8
Java
false
false
1,458
java
/** * Copyright (C) 2004-2015 http://oss.minlia.com/license/framework/2015 * * 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.mycompany.myapp.config; // ///** // * Application constants. // */ //public final class Constants { // // // Spring profile for development, production and "fast", see http://jhipster.github.io/profiles.html // public static final String SPRING_PROFILE_DEVELOPMENT = "dev"; // public static final String SPRING_PROFILE_PRODUCTION = "prod"; // public static final String SPRING_PROFILE_FAST = "fast"; // // Spring profile used when deploying with Spring Cloud (used when deploying to CloudFoundry) // public static final String SPRING_PROFILE_CLOUD = "cloud"; // // Spring profile used when deploying to Heroku // public static final String SPRING_PROFILE_HEROKU = "heroku"; // // public static final String SYSTEM_ACCOUNT = "system"; // // private Constants() { // } //}
ff2af89382854d9215ba1587e952de7056e41628
90183ad77a2a00b800de89bc0430188d782f2898
/app/src/main/java/com/wangshun/ms/activity/TaskManagerSettingActivity.java
349875bb601926d7cb49f640f42770509c483ed8
[]
no_license
WS1009/MobileSafe2
2724376b4b6878db57afd042c792132f55ee92c5
902ca814f497c208acbaee05d424bfaaf9361a2d
refs/heads/master
2021-05-08T21:17:22.381391
2018-01-31T04:36:39
2018-01-31T04:36:40
119,633,894
0
0
null
null
null
null
UTF-8
Java
false
false
2,163
java
package com.wangshun.ms.activity; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import com.wangshun.ms.R; import com.wangshun.ms.service.KillProcessService; import com.wangshun.ms.utils.SharedPreferencesUtils; import com.wangshun.ms.utils.SystemInfoUtils; /** *任务管理器的设置界面 **/ public class TaskManagerSettingActivity extends Activity { private SharedPreferences sp; private CheckBox cb_status_kill_process; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); initUI(); } @Override protected void onStart() { // TODO Auto-generated method stub super.onStart(); if(SystemInfoUtils.isServiceRunning(TaskManagerSettingActivity.this, "com.itheima.mobileguard.services.KillProcessService")){ cb_status_kill_process.setChecked(true); }else{ cb_status_kill_process.setChecked(false); } } private void initUI() { setContentView(R.layout.activity_task_manager_setting); CheckBox cb_status = (CheckBox) findViewById(R.id.cb_status); //设置是否选中 cb_status.setChecked(SharedPreferencesUtils.getBoolean(TaskManagerSettingActivity.this, "is_show_system", false)); cb_status.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { SharedPreferencesUtils.saveBoolean(TaskManagerSettingActivity.this, "is_show_system", isChecked); } }); //定时清理进程 cb_status_kill_process = (CheckBox) findViewById(R.id.cb_status_kill_process); final Intent intent = new Intent(this,KillProcessService.class); cb_status_kill_process.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ startService(intent); }else{ stopService(intent); } } }); } }
85f9081f53935390b550d98d9edd593e4e44b056
8d935d44c34751b53895ce3383dde49073503251
/src/main/java/org/iii/ideas/catering_service/rest/api/QuerySfschoolproductsetBySchoolResponse.java
97892598b4f9f500e6ae0ab89ea481fcc5f09815
[ "Apache-2.0" ]
permissive
NoahChian/Devops
b3483394b8e8189f4647a4ee41d8ceb8267eaebb
3d310dedfd1bd07fcda3d5f4f7ac45a07b90489f
refs/heads/master
2016-09-14T05:41:37.471624
2016-05-11T07:29:28
2016-05-11T07:29:28
58,521,704
0
0
null
null
null
null
UTF-8
Java
false
false
698
java
package org.iii.ideas.catering_service.rest.api; import java.util.ArrayList; import java.util.List; import org.iii.ideas.catering_service.rest.bo.SfSchoolproductsetBO; public class QuerySfschoolproductsetBySchoolResponse extends AbstractApiResponse { private static final long serialVersionUID = -1904135875588581166L; private List<SfSchoolproductsetBO> sfschoolproductsetList = new ArrayList<SfSchoolproductsetBO>(); public List<SfSchoolproductsetBO> getSfschoolproductsetList() { return sfschoolproductsetList; } public void setSfschoolproductsetList(List<SfSchoolproductsetBO> sfschoolproductsetList) { this.sfschoolproductsetList = sfschoolproductsetList; } }
7f158fa657e2ab34cb443a06f0246c23cad9a628
77d288f73e52bd77c565ebe9a503167c77f37b53
/cloud-config-server/src/main/java/com/example/springonedemo/CloudConfigServerApplication.java
802a013313ff48bb93e2c4cf6bec5b3605706524
[]
no_license
Matthew-Dong/springonedemo
8221f4b24f72cc7b5598941c56c3afc836a6b960
132b1e561550c40c9c60783e0ff581c12ab77891
refs/heads/master
2020-03-29T08:32:32.807042
2018-09-17T18:12:42
2018-09-17T18:12:42
null
0
0
null
null
null
null
UTF-8
Java
false
false
426
java
package com.example.springonedemo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.config.server.EnableConfigServer; @EnableConfigServer @SpringBootApplication public class CloudConfigServerApplication { public static void main(String[] args) { SpringApplication.run(CloudConfigServerApplication.class, args); } }
0235a5dd1cd60f5357ec853357f3100230413193
af870b9d500e6fd33fea9b3e113360865a663dc4
/regulatory_center/src/main/java/com/fotic/management/trade/providers/SubmitTradeProvider.java
b1368b58ddddc31bb763eb93e6cfdcb74421ef97
[]
no_license
dengGQ/springcloud-simple-demo
a7a3e8d3ea398fdd50ac3626137aace66dc95b20
5db15a8c9294708c670243892f75f14f0a124a71
refs/heads/master
2022-12-27T23:25:43.391648
2020-01-13T03:58:46
2020-01-13T03:58:46
189,195,731
0
1
null
2022-12-16T11:54:03
2019-05-29T09:37:58
JavaScript
UTF-8
Java
false
false
2,905
java
package com.fotic.management.trade.providers; import java.text.MessageFormat; import java.util.List; import java.util.Map; import org.apache.ibatis.jdbc.SQL; import com.fotic.common.util.PubMethod; import com.fotic.management.trade.entity.SubmitTrade; @SuppressWarnings("unchecked") public class SubmitTradeProvider { public String execCsvFileSql(Map<String, Object> map) { List<SubmitTrade> list = (List<SubmitTrade>) map.get("list"); StringBuilder sb = new StringBuilder(); sb.append("INSERT ALL "); MessageFormat mf = new MessageFormat( "(" + "#'{'list[{0}].name}, #'{'list[{0}].certtype}, #'{'list[{0}].certno},#'{'list[{0}].deptcode}, #'{'list[{0}].generaltype}, #'{'list[{0}].type}, " + "#'{'list[{0}].account}, #'{'list[{0}].tradeid},#'{'list[{0}].areacode}, #'{'list[{0}].dateopened}, #'{'list[{0}].dateclosed}, #'{'list[{0}].currency}, " + "#'{'list[{0}].creditlimit}, #'{'list[{0}].shareaccount},#'{'list[{0}].maxdebt}, #'{'list[{0}].guaranteeway}, #'{'list[{0}].termsfreq}, #'{'list[{0}].monthduration}, " + "#'{'list[{0}].monthunpaid}, #'{'list[{0}].billingdate},#'{'list[{0}].recentpaydate}, #'{'list[{0}].scheduledamount}, #'{'list[{0}].actualpayamount}, #'{'list[{0}].balance}, " + "#'{'list[{0}].curtermspastdue}, #'{'list[{0}].amountpastdue},#'{'list[{0}].amountpastdue30}, #'{'list[{0}].amountpastdue60}, #'{'list[{0}].amountpastdue90}, #'{'list[{0}].apastdue180}, " + "#'{'list[{0}].termspastdue}, #'{'list[{0}].maxtermspastdue},#'{'list[{0}].class5stat}, #'{'list[{0}].accountstat}, #'{'list[{0}].paystat24month}, " + "#'{'list[{0}].dataStatus}, #'{'list[{0}].insertDttm}, #'{'list[{0}].dataSrc}) "); for (int i = 0; i < list.size(); i++) { sb.append( "INTO RHZX_SUBMT_PER_TRADE (NAME,CERTTYPE,CERTNO,DEPTCODE,GENERALTYPE,TYPE," + "ACCOUNT,TRADEID,AREACODE,DATEOPENED,DATECLOSED,CURRENCY," + "CREDITLIMIT,SHAREACCOUNT,MAXDEBT,GUARANTEEWAY,TERMSFREQ,MONTHDURATION," + "MONTHUNPAID,BILLINGDATE,RECENTPAYDATE,SCHEDULEDAMOUNT,ACTUALPAYAMOUNT,BALANCE," + "CURTERMSPASTDUE,AMOUNTPASTDUE,AMOUNTPASTDUE30,AMOUNTPASTDUE60,AMOUNTPASTDUE90,APASTDUE180," + "TERMSPASTDUE,MAXTERMSPASTDUE,CLASS5STAT,ACCOUNTSTAT,PAYSTAT24MONTH," + "DATA_STATUS,INSERT_DTTM,DATA_SRC) VALUES "); sb.append(mf.format(new Object[] { i })); } sb.append(" SELECT 1 FROM dual"); return sb.toString(); } public String queryList(String certno,String dataStatus, String dataSrc) { String sql = new SQL() { { SELECT(" * "); FROM(" RHZX_SUBMT_PER_TRADE"); if(!PubMethod.isEmpty(certno)) { WHERE(" CERTNO ='"+certno+"'"); } if(!PubMethod.isEmpty(dataStatus) && !"0".equals(dataStatus)) { WHERE(" DATA_STATUS ="+dataStatus); } WHERE(" data_src ="+dataSrc); ORDER_BY(" ACCOUNT desc"); } }.toString(); return sql; } }
18ba06c773877e68120a2fb37503dc2d67b19606
1d8ff79e8566b7e8d290fce884b74e51608fc187
/task3-Minesweeper/src/main/java/ru/gaidamaka/ui/MinesweeperView.java
c958512ccaf6d3a256e187189f24903a53705683
[]
no_license
Dross0/FocusStart-Projects
c4f30307c509393a61c003d87f232fe545897100
0d83f815586945e1c24f99e519dced136d6c024d
refs/heads/master
2023-02-08T07:33:48.381529
2020-12-27T18:46:38
2020-12-27T18:46:38
324,404,522
0
0
null
null
null
null
UTF-8
Java
false
false
12,806
java
package ru.gaidamaka.ui; import org.jetbrains.annotations.NotNull; import ru.gaidamaka.exception.ImageReadException; import ru.gaidamaka.game.cell.Cell; import ru.gaidamaka.game.cell.CellType; import ru.gaidamaka.highscoretable.HighScoreTable; import ru.gaidamaka.presenter.Presenter; import ru.gaidamaka.ui.gamefield.GameFieldView; import ru.gaidamaka.ui.highscore.HighScoreWindow; import ru.gaidamaka.userevent.*; import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowEvent; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Objects; public class MinesweeperView implements View { private static final String FONT = "Serif"; private static final int MAX_SCORE_FIELD_CHAR_NUMBER = 3; private static final int IMAGE_SIZE = 50; private static final int MAX_FIELD_WIDTH_SIZE = 32; private static final int MAX_FIELD_HEIGHT_SIZE = 32; private static final int MAX_BOMBS_NUMBER_SIZE = 32; private final JFrame mainWindow; private GameFieldView gameFieldView; private List<ImageIcon> nearBombsIcons; private ImageIcon flagIcon; private ImageIcon bombIcon; private ImageIcon closedCellIcon; private ImageIcon newGameConfigIcon; private ImageIcon highScoreWindowIcon; private Presenter presenter; private JLabel scoreLabel; private JLabel flagsLabel; public MinesweeperView(int gameFieldWidth, int gameFieldHeight) { mainWindow = new JFrame(); mainWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); mainWindow.setTitle("Сапёр"); mainWindow.setResizable(false); mainWindow.setLayout(new GridBagLayout()); initScoreBar(); initGameField(gameFieldWidth, gameFieldHeight); initMenu(); try { initIcons(); } catch (ImageReadException e) { showErrorMessage("Технические неполадки: Отсутсвуют необходимые иконки"); throw e; } mainWindow.pack(); mainWindow.setVisible(true); } public void showErrorMessage(@NotNull String errorMessage) { JPanel contentPanel = new JPanel(); JLabel errorMessageLabel = new JLabel(errorMessage); contentPanel.add(errorMessageLabel); JOptionPane.showMessageDialog( mainWindow, contentPanel, "Ошибка", JOptionPane.ERROR_MESSAGE ); closeApp(); } @Override public void showAbout(@NotNull String aboutText) { Objects.requireNonNull(aboutText, "About text cant be null"); JPanel aboutPanel = new JPanel(); aboutPanel.setLayout(new BoxLayout(aboutPanel, BoxLayout.Y_AXIS)); String[] lines = aboutText.split("\n"); for (String line : lines) { aboutPanel.add(new JLabel(line)); } JOptionPane.showMessageDialog( mainWindow, aboutPanel, "Информация о игре", JOptionPane.INFORMATION_MESSAGE ); } private void closeApp() { mainWindow.setVisible(false); mainWindow.dispatchEvent(new WindowEvent(mainWindow, WindowEvent.WINDOW_CLOSING)); } private void initGameField(int gameFieldWidth, int gameFieldHeight) { GridBagConstraints c = new GridBagConstraints(); c.gridy = 1; c.gridwidth = 2; gameFieldView = new GameFieldView(); gameFieldView.setButtonPreferredWidth(IMAGE_SIZE); gameFieldView.setButtonPreferredHeight(IMAGE_SIZE); gameFieldView.reset(gameFieldWidth, gameFieldHeight, this::fireEvent); mainWindow.add(gameFieldView.getGameFieldPanel(), c); } private void initScoreBar() { scoreLabel = new JLabel(); scoreLabel.setFont(new Font(FONT, Font.BOLD, 20)); flagsLabel = new JLabel(); flagsLabel.setFont(new Font(FONT, Font.BOLD, 20)); resetScoreBoard(); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.anchor = GridBagConstraints.WEST; mainWindow.add(scoreLabel, c); c.gridx = 1; c.anchor = GridBagConstraints.EAST; mainWindow.add(flagsLabel, c); } private ImageIcon readImage(String imageName) { URL imageRes = MinesweeperView.class.getClassLoader().getResource(imageName); if (imageRes == null) { throw new ImageReadException("Cant read image from = {" + imageName + "}"); } return new ImageIcon(imageRes); } private ImageIcon readAndResizeImage(String imageName){ Image scaledImage = readImage(imageName) .getImage() .getScaledInstance(IMAGE_SIZE, IMAGE_SIZE, Image.SCALE_DEFAULT); return new ImageIcon(scaledImage); } private void initIcons() { nearBombsIcons = new ArrayList<>(); for (int i = 0; i < 9; i++) { nearBombsIcons.add(readAndResizeImage(i + ".png")); } closedCellIcon = readAndResizeImage("closedCell.png"); bombIcon = readAndResizeImage("bomb.png"); flagIcon = readAndResizeImage("flag.png"); newGameConfigIcon = readImage("newGameSettings.png"); highScoreWindowIcon = readImage("recordDialog.png"); } private void initMenu() { JMenuBar menu = new JMenuBar(); addMenuItem(menu, "Новая игра", new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { newGameStart(); } } }); addMenuItem(menu, "Таблица рекордов", new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { presenter.onEvent(new ShowHighScoreTableEvent()); } } }); addMenuItem(menu, "О игре", new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { presenter.onEvent(new ShowAboutEvent()); } } }); addMenuItem(menu, "Выход", new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { presenter.onEvent(new ExitGameEvent()); closeApp(); } } }); mainWindow.setJMenuBar(menu); } private void addMenuItem(JMenuBar menuBar, String menuItemTitle, MouseAdapter mouseAdapter) { JMenuItem menuItem = new JMenuItem(menuItemTitle); menuItem.addMouseListener(mouseAdapter); menuBar.add(menuItem); } private JSlider createNewGameConfigSlider(int min, int max, int defaultValue, int majorTickSpacing) { JSlider slider = new JSlider(SwingConstants.HORIZONTAL, min, max, defaultValue); slider.setMajorTickSpacing(majorTickSpacing); slider.setMinorTickSpacing(1); slider.setPaintTicks(true); slider.setPaintLabels(true); return slider; } private void newGameStart() { JPanel newGameConfigurationPanel = new JPanel(); newGameConfigurationPanel.setLayout(new BoxLayout(newGameConfigurationPanel, BoxLayout.Y_AXIS)); JLabel fieldWidthLabel = new JLabel("Ширина поля"); JSlider fieldWidthSlider = createNewGameConfigSlider(1, MAX_FIELD_WIDTH_SIZE, 10, 10); newGameConfigurationPanel.add(fieldWidthLabel); newGameConfigurationPanel.add(fieldWidthSlider); JLabel fieldHeightLabel = new JLabel("Высота поля"); JSlider fieldHeightSlider = createNewGameConfigSlider(1, MAX_FIELD_HEIGHT_SIZE, 10, 10); newGameConfigurationPanel.add(fieldHeightLabel); newGameConfigurationPanel.add(fieldHeightSlider); JLabel bombsNumberLabel = new JLabel("Количество бомб"); JSlider bombsNumberSlider = createNewGameConfigSlider(1, MAX_BOMBS_NUMBER_SIZE, 10, 10); newGameConfigurationPanel.add(bombsNumberLabel); newGameConfigurationPanel.add(bombsNumberSlider); showMessageDialog( newGameConfigurationPanel, "Новая игра", newGameConfigIcon ); int fieldWidth = fieldWidthSlider.getValue(); int fieldHeight = fieldHeightSlider.getValue(); int bombsNumber = bombsNumberSlider.getValue(); gameFieldView.reset(fieldWidth, fieldHeight, this::fireEvent); resetScoreBoard(); mainWindow.pack(); presenter.onEvent(new NewGameEvent( fieldWidth, fieldHeight, bombsNumber )); } private void resetScoreBoard() { updateFlagsNumber(0); updateScore(0); } @Override public void drawCell(@NotNull Cell cell) { Objects.requireNonNull(cell, "Cell cant be null"); if (cell.isMarked()) { gameFieldView.updateCell(cell.getX(), cell.getY(), flagIcon); return; } if (cell.isHidden()) { gameFieldView.updateCell(cell.getX(), cell.getY(), closedCellIcon); } else{ if (cell.getType() == CellType.BOMB){ gameFieldView.updateCell(cell.getX(), cell.getY(), bombIcon); } else{ gameFieldView.updateCell(cell.getX(), cell.getY(), nearBombsIcons.get(cell.getNearBombNumber())); } } } @Override public void fireEvent(@NotNull UserEvent event) { presenter.onEvent(Objects.requireNonNull(event, "Event cant be null")); } private void showDialogWithCenterLabel(JLabel label, int gap) { JDialog dialog = new JDialog(); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JPanel content = new JPanel(); content.setLayout(new BorderLayout(gap, gap)); content.setBorder(BorderFactory.createEmptyBorder(gap, gap, gap, gap)); content.add(label); dialog.add(content); dialog.setVisible(true); dialog.pack(); } @Override public void showLoseScreen() { JLabel loseLabel = new JLabel("Вы проиграли!"); loseLabel.setFont(new Font(FONT, Font.BOLD, 30)); showDialogWithCenterLabel(loseLabel, 30); } @Override public void showWinScreen() { JLabel winLabel = new JLabel("Вы выиграли!"); winLabel.setFont(new Font(FONT, Font.BOLD, 30)); showDialogWithCenterLabel(winLabel, 30); } @Override public void showHighScoreTable(@NotNull HighScoreTable table) { Objects.requireNonNull(table, "Table cant be null"); HighScoreWindow highScoreWindow = new HighScoreWindow(table, new Font(FONT, Font.BOLD, 20)); highScoreWindow.show(); } private String formatScore(int score) { int charsAtScore = String.valueOf(score).length(); return "0".repeat(MAX_SCORE_FIELD_CHAR_NUMBER - charsAtScore) + score; } @Override public void updateScore(int score) { scoreLabel.setText(formatScore(score)); } @Override public void updateFlagsNumber(int flagsNumber) { flagsLabel.setText(String.valueOf(flagsNumber)); } @Override @NotNull public String readPlayerName() { JPanel userNameInputPanel = new JPanel(); userNameInputPanel.setLayout(new BorderLayout()); JTextField userNameInputField = new JTextField(30); userNameInputPanel.add(new JLabel("Ваше имя: "), BorderLayout.LINE_START); userNameInputPanel.add(userNameInputField); do { showMessageDialog( userNameInputPanel, "Вы попали в таблицу рекордов", highScoreWindowIcon ); } while (userNameInputField.getText().isBlank()); return userNameInputField.getText(); } private void showMessageDialog(JPanel panel, String title, ImageIcon image) { JOptionPane.showMessageDialog(mainWindow, panel, title, JOptionPane.QUESTION_MESSAGE, image ); } @Override public void setPresenter(@NotNull Presenter presenter) { this.presenter = Objects.requireNonNull(presenter, "Presenter cant be null"); } }
85d4678f2c9eb843c58e2b3e0050f554c654bb29
9ff9df8f090586eb8f8262aa5dc1d4866c1fbbe3
/src/net/kalinovcic/ld32/BombBehavior.java
e1aee1b49073d851205f306c1aef89b486de2ce6
[ "Apache-2.0" ]
permissive
Kalinovcic/LD32
06e7b6bfcd313650872eb2373c71f17a19712d01
28b1a82a93b2ee08a9b2afe9aefde45f1ccac95d
refs/heads/master
2016-08-04T13:36:43.207784
2015-04-20T12:06:11
2015-04-20T12:06:11
34,143,816
0
0
null
null
null
null
UTF-8
Java
false
false
2,406
java
package net.kalinovcic.ld32; import static org.lwjgl.opengl.GL11.*; public class BombBehavior implements Behavior { public static Behavior instance = new BombBehavior(); private BombBehavior() {} @Override public int getTexture() { return LD32.textureBomb; } @Override public float getSize() { return 48; } @Override public float getSpeedMul() { return 0.3f; } @Override public void labelColor() { glColor3f(1.0f, 0.0f, 0.0f); } @Override public void init(Enemy enemy) { enemy.cooldown = 20; } @Override public void update(Enemy enemy, double timeDelta) { long rvv11 = (long) enemy.cooldown; enemy.cooldown -= timeDelta; long rvv21 = (long) enemy.cooldown; if (enemy.cooldown >= 0 && enemy.cooldown <= 3 && rvv11 != rvv21) { AudioPlayer.setGain(0.7f); AudioPlayer.setPitch(0.9f); AudioPlayer.playWaveSound("warn"); } if (enemy.cooldown >= 0) enemy.texture = LD32.textureBomb; if (enemy.cooldown < 0) enemy.texture = LD32.textureBombIn; enemy.sppr = enemy.sppg = enemy.sppb = 1; if (enemy.cooldown <= 3) if ((int) (enemy.cooldown * 2) % 2 == 1) { enemy.sppr = 0; enemy.sppg = enemy.sppb = 0; } enemy.ang = (float) enemy.cooldown * 90; if (enemy.cooldown < 0 && enemy.cooldown + timeDelta >= 0) for (int i = 0; i < 10; i++) { char c1 = (char) (LD32.random.nextInt('z' - 'a' + 1) + 'a'); char c2 = (char) (LD32.random.nextInt('z' - 'a' + 1) + 'a'); char c3 = (char) (LD32.random.nextInt('z' - 'a' + 1) + 'a'); if (enemy.game.enemies.get(c1 - 'a') == null) { float x = BasicBehavior.instance.getSize() / 2 + (i / 9.0f) * (LD32.WW - BasicBehavior.instance.getSize()); Enemy e = new Enemy(enemy.game, c1 + "" + c2 + c3, x, -BasicBehavior.instance.getSize(), Math.max((float) enemy.game.maxSpeed * 0.2f, 50), BasicBehavior.instance); enemy.game.toAdd.add(e); enemy.game.enemies.set(c1 - 'a', e); } } } }
a40de8ec2a16faa4aa90e0a6d4150e210c7da27c
f7364d80f406f701f475188e6399fd37ae3c356a
/app/src/main/java/com/example/puza/mvpapiimplementation/modules/main/activities/reviewAndCall/mvp/ReviewAndCallModel.java
91423877ab5a9ea72725de3ab6b74efbd827e305
[]
no_license
puja110/Ghumgham
bd7e77947667e824aab0e70e449bf725c6e4e24a
df4691529e677aebd64c8b9eded6c4668c56c2f5
refs/heads/master
2020-05-04T21:40:12.288745
2019-04-04T12:49:47
2019-04-04T12:49:47
179,484,485
1
0
null
null
null
null
UTF-8
Java
false
false
819
java
package com.example.puza.mvpapiimplementation.modules.main.activities.reviewAndCall.mvp; import com.example.puza.mvpapiimplementation.application.network.AppNetwork; import com.example.puza.mvpapiimplementation.application.network.placeReviewsDao.PlaceReviews; import com.example.puza.mvpapiimplementation.helper.PreferencesManager; import io.reactivex.Observable; public class ReviewAndCallModel { PreferencesManager preferencesManager; AppNetwork appNetwork; public ReviewAndCallModel(PreferencesManager preferencesManager, AppNetwork appNetwork) { this.preferencesManager = preferencesManager; this.appNetwork = appNetwork; } /*get the place review */ public Observable<PlaceReviews> getPlaceReviews(String url) { return appNetwork.getPlaceReviews(url); } }
6c999b53fb50eb884f50fc9d809ebc355fcaa28b
a83d6372cd03aa33e60f1e37bda1e43e2c166d2d
/OfficeAutomation/src/com/zdh/service/DebugWorkingService.java
f6997f55de711fe01549ab05d54ae81db90c15ff
[]
no_license
panpengcheng066516/sdmzdhOA
448735abc96b4b805b4aff8a2d6d07ca7a2c5f9e
19b860bf89230ba938cf462a408d222ce390142d
refs/heads/master
2023-02-12T20:09:51.220156
2021-01-18T02:10:38
2021-01-18T02:10:38
294,124,200
1
1
null
null
null
null
UTF-8
Java
false
false
2,322
java
package com.zdh.service; import com.zdh.dao.DebugWorkingDao; import com.zdh.domain.DebugWorking; import com.zdh.domain.DesignWorking; import com.zdh.domain.Project; import java.sql.SQLException; import java.util.List; public class DebugWorkingService { DebugWorkingDao debugWorkingDao = new DebugWorkingDao(); public int addDebugWorking(DebugWorking debugWorking) { int i =0; try { i = debugWorkingDao.addDebugWorking(debugWorking); } catch (SQLException e) { e.printStackTrace(); } return i; } public List<DebugWorking> getDebugWorkingByUsername(String username) { List<DebugWorking> list = null; try { list = debugWorkingDao.getDebugWorkingByUsername(username); } catch (SQLException e) { e.printStackTrace(); } return list; } public List<DebugWorking> getDebugWorkingByDateUsername(String year,String month,String username) { List<DebugWorking> list = null; try { list = debugWorkingDao.getDebugWorkingByDateUsername(year,month,username); } catch (SQLException e) { e.printStackTrace(); } return list; } public int updateDebugWorking(DebugWorking debugWorking) { int i =0; try { i = debugWorkingDao.updateDebugWorking(debugWorking); } catch (SQLException e) { e.printStackTrace(); } return i; } public DebugWorking getDebugWorkingInfo(String debugid) { DebugWorking debugWorking = null; try { debugWorking = debugWorkingDao.getDebugWorkingInfo(debugid); } catch (SQLException e) { e.printStackTrace(); } return debugWorking; } public Project getProjectByid(String debugid) { Project project = null; try { project = debugWorkingDao.getProjectByid(debugid); } catch (SQLException e) { e.printStackTrace(); } return project; } public int deleteDebugWorkingByid(String id) { int i =0; try { i = debugWorkingDao.deleteDebugWorkingByid(id); } catch (SQLException e) { e.printStackTrace(); } return i; } }
61f6e08bf2126d92d74f868b45925a336237f735
2cc3f62365b1e0eca6f196e93ab55eb296dac97e
/ssm/src/main/java/com/my/ssm/demo/service/IUserService.java
e7a811bead48399a8ac89a5aca7ed5c4824a2624
[]
no_license
zsxneil/ssm
a8a02a0d67ed89629b8e56ef09aef5528b64ef9c
3534432428e77efe51b39a2a30f1883258dc61e7
refs/heads/master
2021-01-19T04:54:55.331164
2017-10-13T09:38:18
2017-10-13T09:38:18
87,402,510
0
0
null
null
null
null
UTF-8
Java
false
false
267
java
package com.my.ssm.demo.service; import com.github.pagehelper.PageInfo; import com.my.ssm.demo.model.User; public interface IUserService { User getUserById(int userId); int saveUser(User user); PageInfo<User> findUserListByName(String name); }
436eee05c9958ee4ab5c8f3506d41acfb4ce6e6c
0f6b23808498fafcf0393fef16e3711680b70efc
/fmv-mymedia/src/main/java/org/fagu/fmv/mymedia/classify/ClassifierFactory.java
3d557c3120bc074163826ec12805e7d64a5cfd5e
[]
no_license
f-agu/fmv
cedfea92b1e55e4e10e67b25716daab4ac02ef39
feda060aac3ec0beadf21e18be3858b030e97559
refs/heads/master
2023-07-09T21:59:51.464936
2023-07-05T11:59:23
2023-07-05T11:59:23
79,101,013
4
0
null
2022-12-14T11:08:04
2017-01-16T09:07:23
Java
UTF-8
Java
false
false
1,009
java
package org.fagu.fmv.mymedia.classify; /* * #%L * fmv-mymedia * %% * Copyright (C) 2014 - 2015 fagu * %% * 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. * #L% */ import java.io.File; import java.io.IOException; import org.fagu.fmv.media.Media; import org.fagu.fmv.utils.file.FileFinder; /** * @author f.agu */ public interface ClassifierFactory<F extends FileFinder<M>, M extends Media> { String getTitle(); Classifier<F, M> create(F finder, File destFolder) throws IOException; }
5c7cf67b5a8bbcd25b2bd74873f00107132859ed
2ae93957b9ff9471551b5834e7ed21e71c20abba
/app/src/main/java/com/sit/kaikiliService/activity/HomeScreenActivity.java
311cea670f6c3d872dfc083ef0fed7a2852b079d
[]
no_license
syerragunta/Kaikili_Android_App
73e8302d095de41248dbbc3624bce557e7f18340
0490c49c7744e80651ab14de4ca16443a2555c04
refs/heads/master
2020-04-23T05:42:47.471056
2019-02-28T20:38:39
2019-02-28T20:38:44
170,926,802
0
0
null
null
null
null
UTF-8
Java
false
false
35,561
java
package com.sit.kaikiliService.activity; <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD import android.content.Intent; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.NavigationView; import android.support.design.widget.Snackbar; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; import com.sit.kaikiliService.R; import com.sit.kaikiliService.comman.CircularImageView; import com.sit.kaikiliService.font.TextViewEuphemiaUCASBola; import com.sit.kaikiliService.font.TextViewEuphemiaUCASRegular; ======= ======= >>>>>>> 1/30/2019 ======= >>>>>>> 1/31/2019 ======= >>>>>>> 2/1/2019 ======= >>>>>>> 2/2/2019 ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.os.Bundle; <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/2/2019 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/9/2019 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/14/2019 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/15/2019 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/16/2019 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/16/2019 V1 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/16/2019 V2 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/16/2019 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/18/2019 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/21/2019 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/22/2019 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/23/2019 ======= import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/25/2019 import android.support.design.widget.TabLayout; ======= import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; >>>>>>> 2/26/2019 ======= ======= >>>>>>> 2/28/2019 import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.BottomNavigationView; <<<<<<< HEAD >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.GravityCompat; import android.support.v4.view.ViewPager; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.widget.Toolbar; <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD import android.view.LayoutInflater; <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD ======= import android.view.MenuItem; >>>>>>> 2/2/2019 ======= import android.view.MenuItem; >>>>>>> 2/9/2019 ======= import android.view.MenuItem; >>>>>>> 2/14/2019 ======= import android.view.MenuItem; >>>>>>> 2/15/2019 ======= import android.view.MenuItem; >>>>>>> 2/16/2019 ======= import android.view.MenuItem; >>>>>>> 2/16/2019 V1 ======= import android.view.MenuItem; >>>>>>> 2/16/2019 V2 ======= import android.view.MenuItem; >>>>>>> 2/16/2019 ======= import android.view.MenuItem; >>>>>>> 2/18/2019 ======= import android.view.MenuItem; >>>>>>> 2/21/2019 ======= import android.view.MenuItem; >>>>>>> 2/22/2019 ======= import android.view.MenuItem; >>>>>>> 2/23/2019 ======= import android.view.MenuItem; >>>>>>> 2/25/2019 ======= import android.view.MenuItem; >>>>>>> 2/26/2019 import android.view.View; ======= ======= >>>>>>> 2/28/2019 import android.view.MenuItem; import android.view.View; import com.sit.kaikiliService.KaikiliApplication; <<<<<<< HEAD >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 import com.sit.kaikiliService.R; import com.sit.kaikiliService.font.TextViewEuphemiaUCASRegular; import com.sit.kaikiliService.fragment.EarningsFragment; import com.sit.kaikiliService.fragment.NotificationFragment; import com.sit.kaikiliService.fragment.ProfileFragment; import com.sit.kaikiliService.fragment.ScheduledServicesFragment; <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 1/29/2019 ======= >>>>>>> 1/30/2019 ======= >>>>>>> 1/31/2019 ======= >>>>>>> 2/1/2019 ======= >>>>>>> 2/2/2019 ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 import butterknife.Bind; import butterknife.ButterKnife; /** * Created by ketan patel on 28/1/2019. * [email protected] * Sharva Infotech PVT LTD */ public class HomeScreenActivity extends BaseActivity { // implements NavigationView.OnNavigationItemSelectedListener { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD // @Bind(R.id.menu_top_civ_profile) CircularImageView menu_top_civ_profile; // @Bind(R.id.menu_tv_top_userName) TextViewEuphemiaUCASRegular menu_tv_top_userName; // @Bind(R.id.menu_tv_top_ratingCount) TextViewEuphemiaUCASBola menu_tv_top_ratingCount; // @Bind(R.id.menu_tv_top_serviceCount) TextViewEuphemiaUCASBola menu_tv_top_serviceCount; // // // @Bind(R.id.menu_tv_addService) TextViewEuphemiaUCASRegular menu_tv_addService; // @Bind(R.id.menu_tv_serviceCatalogue) TextViewEuphemiaUCASRegular menu_tv_serviceCatalogue; // @Bind(R.id.menu_tv_serviceHistory) TextViewEuphemiaUCASRegular menu_tv_serviceHistory; // @Bind(R.id.menu_tv_payment) TextViewEuphemiaUCASRegular menu_tv_payment; // @Bind(R.id.menu_tv_profile) TextViewEuphemiaUCASRegular menu_tv_profile; // @Bind(R.id.menu_tv_contactUs) TextViewEuphemiaUCASRegular menu_tv_contactUs; // @Bind(R.id.menu_tv_logout) TextViewEuphemiaUCASRegular menu_tv_logout; ======= ======= >>>>>>> 1/30/2019 ======= >>>>>>> 1/31/2019 ======= >>>>>>> 2/1/2019 @Bind(R.id.home_viewpager)ViewPager home_viewpager; @Bind(R.id.top_title)TextViewEuphemiaUCASRegular top_title; private Toolbar toolbar; <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 1/29/2019 ======= >>>>>>> 1/30/2019 ======= >>>>>>> 1/31/2019 ======= >>>>>>> 2/1/2019 ======= ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 @Bind(R.id.home_viewpager) ViewPager home_viewpager; @Bind(R.id.top_title) TextViewEuphemiaUCASRegular top_title; private Toolbar toolbar; private BottomNavigationView navigation; <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 2/2/2019 ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= private DrawerLayout drawer ; >>>>>>> 2/22/2019 ======= private DrawerLayout drawer ; >>>>>>> 2/23/2019 ======= private DrawerLayout drawer ; >>>>>>> 2/25/2019 ======= private DrawerLayout drawer ; >>>>>>> 2/26/2019 ======= private DrawerLayout drawer ; private KaikiliApplication application; private SharedPreferences preferences; >>>>>>> 2/27/2019 ======= private DrawerLayout drawer ; private KaikiliApplication application; private SharedPreferences preferences; >>>>>>> 2/28/2019 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState ); setContentView( R.layout.activity_home_screen ); ButterKnife.bind( this, this ); <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar ); ======= toolbar = (Toolbar) findViewById( R.id.toolbar ); >>>>>>> 1/29/2019 ======= toolbar = (Toolbar) findViewById( R.id.toolbar ); >>>>>>> 1/30/2019 ======= toolbar = (Toolbar) findViewById( R.id.toolbar ); >>>>>>> 1/31/2019 ======= toolbar = (Toolbar) findViewById( R.id.toolbar ); >>>>>>> 2/1/2019 setSupportActionBar( toolbar ); ======= ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 toolbar = (Toolbar) findViewById( R.id.toolbar ); setSupportActionBar( toolbar ); navigation = (BottomNavigationView) findViewById( R.id.navigation ); navigation.setOnNavigationItemSelectedListener( mOnNavigationItemSelectedListener ); <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 2/2/2019 ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 DrawerLayout drawer = (DrawerLayout) findViewById( R.id.drawer_layout ); ======= ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 toolbar = (Toolbar) findViewById( R.id.toolbar ); setSupportActionBar( toolbar ); ======= ======= >>>>>>> 2/28/2019 toolbar = (Toolbar) findViewById( R.id.toolbar ); setSupportActionBar( toolbar ); application = (KaikiliApplication) getApplicationContext(); preferences = application.getSharedPreferences(); <<<<<<< HEAD >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 navigation = (BottomNavigationView) findViewById( R.id.navigation ); navigation.setOnNavigationItemSelectedListener( mOnNavigationItemSelectedListener ); drawer = (DrawerLayout) findViewById( R.id.drawer_layout ); <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close ); drawer.addDrawerListener( toggle ); toggle.syncState(); <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD // NavigationView navigationView = (NavigationView) findViewById( R.id.nav_view ); // navigationView.setNavigationItemSelectedListener( this ); } ======= ======= >>>>>>> 1/30/2019 ======= >>>>>>> 1/31/2019 ======= >>>>>>> 2/1/2019 // Create an adapter that knows which fragment should be shown on each page SimpleFragmentPagerAdapter adapter = new SimpleFragmentPagerAdapter(this, getSupportFragmentManager()); home_viewpager.setAdapter(adapter); home_viewpager.setCurrentItem( 0 ); setUpToolbar("Home"); } public void setUpToolbar(final String title) { top_title.setText(title); ======= ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 // Create an adapter that knows which fragment should be shown on each page SimpleFragmentPagerAdapter adapter = new SimpleFragmentPagerAdapter( this, getSupportFragmentManager() ); home_viewpager.setAdapter( adapter ); home_viewpager.setCurrentItem( 0 ); setUpToolbar( "Schedule Service" ); <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD home_viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { public void onPageScrollStateChanged(int state) {} ======= ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 home_viewpager.addOnPageChangeListener( new ViewPager.OnPageChangeListener() { public void onPageScrollStateChanged(int state) { } <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } public void onPageSelected(int position) { // Check if this is the page you want. <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD if(position == 0){ navigation.setSelectedItemId(R.id.navigation_home); }else if (position ==1){ navigation.setSelectedItemId(R.id.navigation_notification); }else if (position ==2){ navigation.setSelectedItemId(R.id.navigation_earnings); }else if (position ==3){ navigation.setSelectedItemId(R.id.navigation_profile); } } }); ======= ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 if (position == 0) { navigation.setSelectedItemId( R.id.navigation_home ); } else if (position == 1) { navigation.setSelectedItemId( R.id.navigation_notification ); } else if (position == 2) { navigation.setSelectedItemId( R.id.navigation_earnings ); } else if (position == 3) { navigation.setSelectedItemId( R.id.navigation_profile ); } } } ); <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 } public void setUpToolbar(final String title) { top_title.setText( title ); <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 2/2/2019 ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 } <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD ======= >>>>>>> 2/2/2019 ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 // private void setupTabIcons() { // // TextViewEuphemiaUCASRegular tabOne = (TextViewEuphemiaUCASRegular) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); // tabOne.setText("Home"); // tabOne.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab_home, 0, 0); // home_sliding_tabs.getTabAt(0).setCustomView(tabOne); // // TextViewEuphemiaUCASRegular tabTwo = (TextViewEuphemiaUCASRegular) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); // tabTwo.setText("Notification"); // tabTwo.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tab_notification, 0, 0); // home_sliding_tabs.getTabAt(1).setCustomView(tabTwo); // // TextViewEuphemiaUCASRegular tabThree = (TextViewEuphemiaUCASRegular) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); // tabThree.setText("Earnings"); // tabThree.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.earnings, 0, 0); // home_sliding_tabs.getTabAt(2).setCustomView(tabThree); // // TextViewEuphemiaUCASRegular tabFore = (TextViewEuphemiaUCASRegular) LayoutInflater.from(this).inflate(R.layout.custom_tab, null); // tabFore.setText("Profile"); // tabFore.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.profile, 0, 0); // home_sliding_tabs.getTabAt(3).setCustomView(tabFore); // } <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 1/29/2019 ======= >>>>>>> 1/30/2019 ======= >>>>>>> 1/31/2019 ======= >>>>>>> 2/1/2019 ======= >>>>>>> 2/2/2019 ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 @Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById( R.id.drawer_layout ); if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } else { super.onBackPressed(); } } public void callAddService(View view) { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/22/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/23/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/25/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/26/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/27/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/28/2019 Intent intent = new Intent( this, AddServiceActivity.class ); startActivity( intent ); } public void callServiceCatalogue(View view) { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/22/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/23/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/25/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/26/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/27/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/28/2019 Intent intent = new Intent( this, ServiceCatalogueActivity.class ); startActivity( intent ); } <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD // @Override // public boolean onOptionsItemSelected(MenuItem item) { // // return super.onOptionsItemSelected( item ); // } // // @SuppressWarnings("StatementWithEmptyBody") // @Override // public boolean onNavigationItemSelected(MenuItem item) { // // Handle navigation view item clicks here. // int id = item.getItemId(); // DrawerLayout drawer = (DrawerLayout) findViewById( R.id.drawer_layout ); // drawer.closeDrawer( GravityCompat.START ); // return true; // } ======= ======= >>>>>>> 1/30/2019 ======= >>>>>>> 1/31/2019 ======= >>>>>>> 2/1/2019 public void callTabHome(View view) { home_viewpager.setCurrentItem( 0 ); top_title.setText("Home"); } public void callTabNotification(View view) { home_viewpager.setCurrentItem(1); top_title.setText("Notification"); } public void callTabEarnings(View view) { home_viewpager.setCurrentItem(2); top_title.setText("Earnings"); } public void callTabProfile(View view) { home_viewpager.setCurrentItem(3); top_title.setText("Profile"); } ======= >>>>>>> 2/2/2019 ======= >>>>>>> 2/9/2019 ======= ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 public void callServiceHistory(View view) { // Intent intent = new Intent( this, ServiceCatalogueActivity.class ); // startActivity( intent ); ======= public void callServiceHistory(View view) { Intent intent = new Intent( this, ServiceHistoryActivity.class ); startActivity( intent ); >>>>>>> 2/21/2019 } public void callPaymentInfo(View view) { // Intent intent = new Intent( this, .class ); // startActivity( intent ); ======= ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 public void callServiceHistory(View view) { if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } Intent intent = new Intent( this, ServiceHistoryActivity.class ); startActivity( intent ); } public void callPaymentInfo(View view) { if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } Intent intent = new Intent( this, BankDetailsActivity.class ); startActivity( intent ); <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 } public void callProfile(View view) { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/22/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/23/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/25/2019 ======= if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } >>>>>>> 2/26/2019 ======= ======= >>>>>>> 2/28/2019 } public void callLogout(View view) { if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } SharedPreferences.Editor editor = preferences.edit(); editor.putString( "sp_id", "" ); editor.putString( "first_name", "" ); editor.putString( "last_name", "" ); editor.putString( "email", "" ); editor.putString( "dob", "" ); editor.putString( "gender", ""); editor.putString( "mobile_no", "" ); editor.commit(); Intent intent = new Intent(this,PhoneNoValidationActivity.class); startActivity(intent); overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left); finish(); } public void callProfile(View view) { if (drawer.isDrawerOpen( GravityCompat.START )) { drawer.closeDrawer( GravityCompat.START ); } <<<<<<< HEAD >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 Intent intent = new Intent( this, ProfileEditActivity.class ); startActivity( intent ); } <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter { private Context mContext; public SimpleFragmentPagerAdapter(Context context, FragmentManager fm) { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD super(fm); ======= super( fm ); >>>>>>> 2/2/2019 ======= super( fm ); >>>>>>> 2/9/2019 ======= super( fm ); >>>>>>> 2/14/2019 ======= super( fm ); >>>>>>> 2/15/2019 ======= super( fm ); >>>>>>> 2/16/2019 ======= super( fm ); >>>>>>> 2/16/2019 V1 ======= super( fm ); >>>>>>> 2/16/2019 V2 ======= super( fm ); >>>>>>> 2/16/2019 ======= super( fm ); >>>>>>> 2/18/2019 ======= super( fm ); >>>>>>> 2/21/2019 ======= super( fm ); >>>>>>> 2/22/2019 ======= super( fm ); >>>>>>> 2/23/2019 ======= super( fm ); >>>>>>> 2/25/2019 ======= super( fm ); >>>>>>> 2/26/2019 ======= super( fm ); >>>>>>> 2/27/2019 ======= super( fm ); >>>>>>> 2/28/2019 mContext = context; } // This determines the fragment for each tab @Override public android.support.v4.app.Fragment getItem(int position) { if (position == 0) { return new ScheduledServicesFragment(); <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD } else if (position == 1){ return new NotificationFragment(); } else if (position == 2){ return new EarningsFragment(); } else if (position == 3){ ======= ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 } else if (position == 1) { return new NotificationFragment(); } else if (position == 2) { return new EarningsFragment(); } else if (position == 3) { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 2/2/2019 ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 return new ProfileFragment(); } else { return new ScheduledServicesFragment(); } } // This determines the number of tabs @Override public int getCount() { return 4; } } <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 1/29/2019 ======= >>>>>>> 1/30/2019 ======= >>>>>>> 1/31/2019 ======= >>>>>>> 2/1/2019 ======= ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case R.id.navigation_home: if (home_viewpager.getCurrentItem() != 0) { home_viewpager.setCurrentItem( 0 ); top_title.setText( "Schedule Service" ); } return true; case R.id.navigation_notification: if (home_viewpager.getCurrentItem() != 1) { home_viewpager.setCurrentItem( 1 ); top_title.setText( "Notification" ); } return true; case R.id.navigation_earnings: if (home_viewpager.getCurrentItem() != 2) { home_viewpager.setCurrentItem( 2 ); top_title.setText( "Earnings" ); } return true; case R.id.navigation_profile: if (home_viewpager.getCurrentItem() != 3) { home_viewpager.setCurrentItem( 3 ); top_title.setText( "Profile" ); } return true; } return false; } }; <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 2/2/2019 ======= >>>>>>> 2/9/2019 ======= >>>>>>> 2/14/2019 ======= >>>>>>> 2/15/2019 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/16/2019 V1 ======= >>>>>>> 2/16/2019 V2 ======= >>>>>>> 2/16/2019 ======= >>>>>>> 2/18/2019 ======= >>>>>>> 2/21/2019 ======= >>>>>>> 2/22/2019 ======= >>>>>>> 2/23/2019 ======= >>>>>>> 2/25/2019 ======= >>>>>>> 2/26/2019 ======= >>>>>>> 2/27/2019 ======= >>>>>>> 2/28/2019 }
e85d71650af54f0988c74600034ceaa80f698e32
9fe800087ef8cc6e5b17fa00f944993b12696639
/batik-svggen/src/main/java/org/apache/batik/svggen/font/table/Coverage.java
e527b12c9f8c0d1e57d75bba5abdbeb9e3ef5616
[ "Apache-2.0" ]
permissive
balabit-deps/balabit-os-7-batik
14b80a316321cbd2bc29b79a1754cc4099ce10a2
652608f9d210de2d918d6fb2146b84c0cc771842
refs/heads/master
2023-08-09T03:24:18.809678
2023-05-22T20:34:34
2023-05-27T08:21:21
158,242,898
0
0
Apache-2.0
2023-07-20T04:18:04
2018-11-19T15:03:51
Java
UTF-8
Java
false
false
1,688
java
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You 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.apache.batik.svggen.font.table; import java.io.IOException; import java.io.RandomAccessFile; /** * * @author <a href="mailto:[email protected]">David Schweinsberg</a> * @version $Id: Coverage.java 1733416 2016-03-03 07:07:13Z gadams $ */ public abstract class Coverage { public abstract int getFormat(); /** * @param glyphId The ID of the glyph to find. * @return The index of the glyph within the coverage, or -1 if the glyph * can't be found. */ public abstract int findGlyph(int glyphId); protected static Coverage read(RandomAccessFile raf) throws IOException { Coverage c = null; int format = raf.readUnsignedShort(); if (format == 1) { c = new CoverageFormat1(raf); } else if (format == 2) { c = new CoverageFormat2(raf); } return c; } }
1cfeda978e6c6aa4169e77ec5148409ce172d066
4a02836c2e4b96c150c5ba6814ffed710180fd77
/common/src/main/java/com/example/common/pattern/creationalPattern/simpleFactory/FactoryPatternDemo.java
28adc2d2262ff15c94b41a1866fcb313c36df0e0
[]
no_license
shanshuaiqi/JavaSE
8c0a7752eae41b977c9a5ceb33ead2d034db019a
a8448613fd039cafe9d2f58a1fb4e1cce1cc07ba
refs/heads/master
2022-07-07T00:23:30.664416
2019-11-19T09:23:26
2019-11-19T09:23:26
216,462,174
3
0
null
2022-06-21T02:15:59
2019-10-21T02:34:50
CSS
UTF-8
Java
false
false
2,911
java
package com.example.common.pattern.creationalPattern.simpleFactory; /** * 使用该工厂,通过传递类型信息来获取实体类的对象。 * * @author ssq * @date 2019-11-08 下午 2:42 */ public class FactoryPatternDemo { // 意图:定义一个创建对象的接口,让其子类自己决定实例化哪一个工厂类,工厂模式使其创建过程延迟到子类进行。 // // 主要解决:主要解决接口选择的问题。 // // 何时使用:我们明确地计划不同条件下创建不同实例时。 // // 如何解决:让其子类实现工厂接口,返回的也是一个抽象的产品。 // // 关键代码:创建过程在其子类执行。 // // 应用实例: 1、您需要一辆汽车,可以直接从工厂里面提货,而不用去管这辆汽车是怎么做出来的,以及这个汽车里面的具体实现。 // 2、Hibernate 换数据库只需换方言和驱动就可以。 // // 优点: // 1、一个调用者想创建一个对象,只要知道其名称就可以了。 // 2、扩展性高,如果想增加一个产品,只要扩展一个工厂类就可以。 // 3、屏蔽产品的具体实现,调用者只关心产品的接口。 // // 缺点:每次增加一个产品时,都需要增加一个具体类和对象实现工厂,使得系统中类的个数成倍增加,在一定程度上增加了系统的复杂度, // 同时也增加了系统具体类的依赖。这并不是什么好事。 // // 使用场景: 1、日志记录器:记录可能记录到本地硬盘、系统事件、远程服务器等,用户可以选择记录日志到什么地方。 // 2、数据库访问,当用户不知道最后系统采用哪一类数据库,以及数据库可能有变化时。 // 3、设计一个连接服务器的框架,需要三个协议,"POP3"、"IMAP"、"HTTP",可以把这三个作为产品类,共同实现一个接口。 // // 注意事项:作为一种创建类模式,在任何需要生成复杂对象的地方,都可以使用工厂方法模式。 // 有一点需要注意的地方就是复杂对象适合使用工厂模式,而简单对象,特别是只需要通过 new 就可以完成创建的对象,无需使用工厂模式。 // 如果使用工厂模式,就需要引入一个工厂类,会增加系统的复杂度。 public static void main(String[] args) { ShapeFactory shapeFactory = new ShapeFactory(); //获取 Circle 的对象,并调用它的 draw 方法 Shape shape1 = shapeFactory.getShape("CIRCLE"); //调用 Circle 的 draw 方法 shape1.draw(); //获取 Rectangle 的对象,并调用它的 draw 方法 Shape shape2 = shapeFactory.getShape("RECTANGLE"); //调用 Rectangle 的 draw 方法 shape2.draw(); //获取 Square 的对象,并调用它的 draw 方法 Shape shape3 = shapeFactory.getShape("SQUARE"); //调用 Square 的 draw 方法 shape3.draw(); } }
647095b097c37d767412178c676c68b3d767fbe3
12a99ab3fe76e5c7c05609c0e76d1855bd051bbb
/src/main/java/com/alipay/api/domain/NoticeTemplateArgs.java
d255e9b147217a7e3901bd2baebb17558aa99435
[ "Apache-2.0" ]
permissive
WindLee05-17/alipay-sdk-java-all
ce2415cfab2416d2e0ae67c625b6a000231a8cfc
19ccb203268316b346ead9c36ff8aa5f1eac6c77
refs/heads/master
2022-11-30T18:42:42.077288
2020-08-17T05:57:47
2020-08-17T05:57:47
null
0
0
null
null
null
null
UTF-8
Java
false
false
660
java
package com.alipay.api.domain; import java.util.Date; import com.alipay.api.AlipayObject; import com.alipay.api.internal.mapping.ApiField; /** * 通知内容模板 * * @author auto create * @since 1.0, 2019-01-03 10:33:05 */ public class NoticeTemplateArgs extends AlipayObject { private static final long serialVersionUID = 1175121918517641389L; /** * 课程开始时间 */ @ApiField("course_start_time") private Date courseStartTime; public Date getCourseStartTime() { return this.courseStartTime; } public void setCourseStartTime(Date courseStartTime) { this.courseStartTime = courseStartTime; } }
b1f94dc86be746bde3413fd92e0707b8e7f7da28
efa7935f77f5368e655c072b236d598059badcff
/src/com/sammyun/plugin/alipayDual/AlipayDualPlugin.java
e6f7a62bbbcfc1fbc21b918e5affef82b9f9963b
[]
no_license
ma-xu/Library
c1404f4f5e909be3e5b56f9884355e431c40f51b
766744898745f8fad31766cafae9fd4db0318534
refs/heads/master
2022-02-23T13:34:47.439654
2016-06-03T11:27:21
2016-06-03T11:27:21
null
0
0
null
null
null
null
UTF-8
Java
false
false
6,109
java
/* * Copyright 2012-2014 sammyun.com.cn. All rights reserved. * Support: http://www.sammyun.com.cn * License: http://www.sammyun.com.cn/license */ package com.sammyun.plugin.alipayDual; import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; import javax.servlet.http.HttpServletRequest; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Component; import com.sammyun.Setting; import com.sammyun.entity.Payment; import com.sammyun.entity.PluginConfig; import com.sammyun.plugin.PaymentPlugin; import com.sammyun.util.SettingUtils; /** * Plugin - 支付宝(双接口) * */ @Component("alipayDualPlugin") public class AlipayDualPlugin extends PaymentPlugin { @Override public String getName() { return "支付宝(双接口)"; } @Override public String getVersion() { return "1.0"; } @Override public String getAuthor() { return "Sencloud"; } @Override public String getSiteUrl() { return "http://www.sammyun.com.cn"; } @Override public String getInstallUrl() { return "alipay_dual/install.ct"; } @Override public String getUninstallUrl() { return "alipay_dual/uninstall.ct"; } @Override public String getSettingUrl() { return "alipay_dual/setting.ct"; } @Override public String getRequestUrl() { return "https://mapi.alipay.com/gateway.do"; } @Override public RequestMethod getRequestMethod() { return RequestMethod.get; } @Override public String getRequestCharset() { return "UTF-8"; } @Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { Setting setting = SettingUtils.get(); PluginConfig pluginConfig = getPluginConfig(); Payment payment = getPayment(sn); Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("service", "trade_create_by_buyer"); parameterMap.put("partner", pluginConfig.getAttribute("partner")); parameterMap.put("_input_charset", "utf-8"); parameterMap.put("sign_type", "MD5"); parameterMap.put("return_url", getNotifyUrl(sn, NotifyMethod.sync)); parameterMap.put("notify_url", getNotifyUrl(sn, NotifyMethod.async)); parameterMap.put("out_trade_no", sn); parameterMap.put("subject", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 60)); parameterMap.put("body", StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 600)); parameterMap.put("payment_type", "1"); parameterMap.put("logistics_type", "EXPRESS"); parameterMap.put("logistics_fee", "0"); parameterMap.put("logistics_payment", "SELLER_PAY"); parameterMap.put("price", payment.getAmount().setScale(2).toString()); parameterMap.put("quantity", "1"); parameterMap.put("seller_id", pluginConfig.getAttribute("partner")); parameterMap.put("total_fee", payment.getAmount().setScale(2).toString()); parameterMap.put("show_url", setting.getSiteUrl()); parameterMap.put("paymethod", "directPay"); parameterMap.put("exter_invoke_ip", request.getLocalAddr()); parameterMap.put("extra_common_param", "preschoolEdu"); parameterMap.put("sign", generateSign(parameterMap)); return parameterMap; } @Override public boolean verifyNotify(String sn, NotifyMethod notifyMethod, HttpServletRequest request) { PluginConfig pluginConfig = getPluginConfig(); Payment payment = getPayment(sn); if (generateSign(request.getParameterMap()).equals(request.getParameter("sign")) && pluginConfig.getAttribute("partner").equals(request.getParameter("seller_id")) && sn.equals(request.getParameter("out_trade_no")) && ("WAIT_SELLER_SEND_GOODS".equals(request.getParameter("trade_status")) || "TRADE_SUCCESS".equals(request.getParameter("trade_status")) || "TRADE_FINISHED".equals(request.getParameter("trade_status"))) && payment.getAmount().compareTo(new BigDecimal(request.getParameter("total_fee"))) == 0) { Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("service", "notify_verify"); parameterMap.put("partner", pluginConfig.getAttribute("partner")); parameterMap.put("notify_id", request.getParameter("notify_id")); if ("true".equals(post("https://mapi.alipay.com/gateway.do", parameterMap))) { return true; } } return false; } @Override public boolean verifyMobileNotify(String sn, NotifyMethod notifyMethod, HttpServletRequest request) { // TODO Auto-generated method stub return false; } @Override public String getNotifyMessage(String sn, NotifyMethod notifyMethod, HttpServletRequest request) { if (notifyMethod == NotifyMethod.async) { return "success"; } return null; } @Override public Integer getTimeout() { return 21600; } /** * 生成签名 * * @param parameterMap 参数 * @return 签名 */ private String generateSign(Map<String, ?> parameterMap) { PluginConfig pluginConfig = getPluginConfig(); return DigestUtils.md5Hex(joinKeyValue(new TreeMap<String, Object>(parameterMap), null, pluginConfig.getAttribute("key"), "&", true, "sign_type", "sign")); } }
bd833eb22407b2cb66551415cc8a48d64085e0a1
d7c5121237c705b5847e374974b39f47fae13e10
/airspan.netspan/src/main/java/Netspan/NBI_17_5/Inventory/SiteCreate.java
cc5ad09ad26daefb45a870f681ce1517fcb3722f
[]
no_license
AirspanNetworks/SWITModules
8ae768e0b864fa57dcb17168d015f6585d4455aa
7089a4b6456621a3abd601cc4592d4b52a948b57
refs/heads/master
2022-11-24T11:20:29.041478
2020-08-09T07:20:03
2020-08-09T07:20:03
184,545,627
1
0
null
2022-11-16T12:35:12
2019-05-02T08:21:55
Java
UTF-8
Java
false
false
1,526
java
package Netspan.NBI_17_5.Inventory; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for anonymous complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType&gt; * &lt;complexContent&gt; * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt; * &lt;sequence&gt; * &lt;element name="Site" type="{http://Airspan.Netspan.WebServices}Site" minOccurs="0"/&gt; * &lt;/sequence&gt; * &lt;/restriction&gt; * &lt;/complexContent&gt; * &lt;/complexType&gt; * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "site" }) @XmlRootElement(name = "SiteCreate") public class SiteCreate { @XmlElement(name = "Site") protected Site site; /** * Gets the value of the site property. * * @return * possible object is * {@link Site } * */ public Site getSite() { return site; } /** * Sets the value of the site property. * * @param value * allowed object is * {@link Site } * */ public void setSite(Site value) { this.site = value; } }
956ca533e63d67e9ca63eb80664394287b25e67f
68e810683374564684b5397bf53acd7057f8ecfd
/src/abstraction/OnlineStudent.java
446217776c8ae6d8fb78ae847d2a0c9473e1aefc
[]
no_license
sefarash/Abstraction
11f3e9f4fe9febef9362db61a8c6bcff2df70c72
2e5b60214fe7368a660065d3f16ec418298f0207
refs/heads/master
2020-03-21T12:33:05.521747
2018-06-25T07:27:52
2018-06-25T07:27:52
138,558,557
0
0
null
null
null
null
UTF-8
Java
false
false
288
java
package abstraction; public class OnlineStudent extends Student{ @Override public void attendClass() { // TODO Auto-generated method stub } public static void main(String[] args) { //No Object can be created for Abstract CLass Student s = new Student(); } }
5513faeb9c62364c0fda71fb4dea00e4527b983d
93d45a4908aab9418ce4b8487e5d66d9d133eb3a
/src/main/java/com/pengjunlee/domain/BodySetEntity.java
039319dba54a0923d32b45c19a54220cdf2099df
[]
no_license
pengjunlee/pink-photo-server
d92a5465cd0518ba40bd2072e833214fbfbe3080
742e0493d9b26cff073ec49b998633be4bd9729b
refs/heads/master
2022-11-18T18:08:17.170748
2019-11-22T05:48:28
2019-11-22T05:48:28
219,399,536
0
0
null
2022-11-16T11:57:41
2019-11-04T02:18:54
Java
UTF-8
Java
false
false
1,217
java
package com.pengjunlee.domain; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; /** * @author pengjunlee * @create 2019-09-03 9:30 */ @Data @TableName("tbl_body_set")//@TableName中的值对应着表名 public class BodySetEntity extends BaseDomain { /** * 主键 * * @TableId中可以决定主键的类型,不写会采取默认值,默认值可以在yml中配置 AUTO: 数据库ID自增 * INPUT: 用户输入ID * ID_WORKER: 全局唯一ID,Long类型的主键 * ID_WORKER_STR: 字符串全局唯一ID * UUID: 全局唯一ID,UUID类型的主键 * NONE: 该类型为未设置主键类型 */ @TableId(type = IdType.AUTO) private Long id; // 主键ID private Long deviceId; // 设备ID private String poseType; // 行 private Long poseStyleId; // 列 private Integer topBottom; private Integer leftRight; private Integer upDown; private Integer rotate; public void init() { this.topBottom = 0; this.leftRight = 0; this.upDown = 0; this.rotate = 0; } }
c30be2d3a66fedfcca164802ab0099f19cf1a2c7
89267cde95e4591913e1a7c11aa38c8f911ea5b0
/embededlabcontrolerapi/src/main/java/com/szu/user/dao/UserDao.java
91e6d7cdf0b30970627ca48d4e70a9a004a17d22
[]
no_license
kamyang/dubbo
8965dc22fd7a2f48ab13118c4e6fc9021749f2cf
a345c16cf3fd4d7f7a19c5b1fc644a843043ea13
refs/heads/master
2021-07-23T19:43:47.765649
2017-10-31T19:53:26
2017-10-31T19:53:26
null
0
0
null
null
null
null
UTF-8
Java
false
false
184
java
package com.szu.user.dao; import com.szu.user.BaseDao; import com.szu.user.pojo.User; /** * Created by kamyang on 2017/10/30. */ public interface UserDao extends BaseDao<User> { }
380656fde1091b42fd229687a979a54cb4645e75
51166ec08de08954e77bf118c1d54bd5e6210bf3
/Jpa_test02/src/main/java/cn/hdj/domain/Role.java
ad5f4a21c2c7c2ff07561893e252c3e2b99dedd8
[]
no_license
xiachuang/myJavaStudy
84f080b3a802c11338316672b2b13616bd338293
4bafe057cdc6df5552ce381e29dbcbfed7211cca
refs/heads/master
2022-12-14T16:41:13.194772
2020-09-20T17:15:46
2020-09-20T17:15:46
297,125,234
0
0
null
null
null
null
UTF-8
Java
false
false
1,539
java
package cn.hdj.domain; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; import java.util.HashSet; import java.util.Set; @Entity @Table(name = "role") public class Role implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "role_id") private Integer roleId; @Column(name = "role_name") private String roleName; @Column(name = "role_level") private String roleLevel; @ManyToMany(mappedBy = "roles",cascade = CascadeType.PERSIST) @NotFound(action= NotFoundAction.IGNORE) private Set<User> users=new HashSet<>(); public Integer getRoleId() { return roleId; } public void setRoleId(Integer roleId) { this.roleId = roleId; } public String getRoleName() { return roleName; } public Set<User> getUsers() { return users; } public void setUsers(Set<User> users) { this.users = users; } public void setRoleName(String roleName) { this.roleName = roleName; } public String getRoleLevel() { return roleLevel; } public void setRoleLevel(String roleLevel) { this.roleLevel = roleLevel; } @Override public String toString() { return "Role{" + "roleId=" + roleId + ", roleName='" + roleName + '\'' + ", roleLevel='" + roleLevel + '\'' + '}'; } }
ba08df6515cabca9bd67ec36d01dcb64a232527a
d785392f8b0f6749ee29c6ac2d48c947f2c13c3b
/InterviewBit/StacksAndQueue/RainWaterTrap.java
b40bb845922536be7516cbd145fea066c9c3d506
[]
no_license
abnayak/brainz
eeae70e72d548c1b340fd7846003b6ef70f18291
a070da468522fc1276f49b4097838bb65d4b0b1f
refs/heads/master
2020-04-03T20:21:26.445618
2018-06-04T08:15:07
2018-06-04T08:15:07
28,757,396
1
2
null
null
null
null
UTF-8
Java
false
false
1,542
java
package StacksAndQueue; import java.util.ArrayList; import java.util.List; /** * Created by abhijeet on 10/11/16. * https://www.interviewbit.com/problems/rain-water-trapped/ */ public class RainWaterTrap { public static void main(String[] args) { int[] walls = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}; List<Integer> list = new ArrayList<>(); for (int i : walls) { list.add(i); } System.out.println(trap(list)); } // DO NOT MODIFY THE LIST public static int trap(final List<Integer> a) { int[] fromHead = new int[a.size()]; int[] fromTail = new int[a.size()]; int waterStored = 0; if (a.size() < 3) return waterStored; fromHead[0] = a.get(0); fromTail[a.size() - 1] = a.get(a.size() - 1); for (int i = 1; i < a.size(); i++) { if (fromHead[i - 1] < a.get(i)) fromHead[i] = a.get(i); else fromHead[i] = fromHead[i - 1]; } for (int i = a.size() - 2; i >= 0; i--) { if (fromTail[i + 1] < a.get(i)) fromTail[i] = a.get(i); else fromTail[i] = fromTail[i + 1]; } for (int i = 1; i < a.size() - 1; i++) { int sideWallHeight = fromHead[i - 1] < fromTail[i + 1] ? fromHead[i - 1] : fromTail[i + 1]; if (sideWallHeight > a.get(i)) { waterStored += (sideWallHeight - a.get(i)); } } return waterStored; } }
3e5dcff5e89c96aa01db944bd99810a654eb468e
9b9645faeb4728f17a62fe1248c81b9cd2f64d70
/src/main/java/org/pact/java/example/HttpServerVerticle.java
16a16c7da22a131f9028ff23707f0ef8d6f918ea
[]
no_license
cpramik/Pact
c399e3bc7dc3b947e4651829bc7c56ec263c9b92
36746bb7e6acf5235a13e4b0cfed203e31380706
refs/heads/master
2020-04-27T23:45:08.140418
2019-03-10T07:01:19
2019-03-10T07:01:19
174,788,929
0
0
null
null
null
null
UTF-8
Java
false
false
1,067
java
package org.pact.java.example; import io.vertx.core.AbstractVerticle; import io.vertx.core.Handler; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.http.HttpServerRequest; import io.vertx.ext.web.Router; public class HttpServerVerticle extends AbstractVerticle{ @Override public void start() { vertx.createHttpServer(new HttpServerOptions()).requestHandler(requestHandler()) .listen(8081, result -> { if (result.succeeded()) { System.out.println("Server started---------------"); } else { System.out.println("Server failed to start---------------"); } }); } private Handler<HttpServerRequest> requestHandler() { Router router = Router.router(vertx); registerTestUserURI(router); return router::accept; } private void registerTestUserURI(Router router) { UserResource resource = new UserResource(new UserService()); router.get("/users").blockingHandler(resource::getUsers, false); router.get("/users/:userId").handler(resource::getUserById); router.post("/users").handler(resource::createUser); } }
db30d6171f0ba9b4e3107f6403f0b71905bd560c
f58e8e2a4018950066ddf30f7ced2275fbc882be
/src/main/java/com/jobexchange/model/Amount.java
2b62c97c07e0423b7646c3527acfd4188b606b4f
[]
no_license
girishkambli/job-seeker-matching-engine
c41fd0e6e9959f9964928cb014fd561217c3d834
4ce683f4c223b2bb1ae2ff87c0b2033e1b3974fd
refs/heads/master
2022-12-30T05:37:16.009122
2020-10-21T23:50:51
2020-10-21T23:50:51
175,947,285
0
0
null
null
null
null
UTF-8
Java
false
false
599
java
package com.jobexchange.model; import java.math.BigDecimal; import java.util.Currency; public class Amount { private Currency currency; private BigDecimal value; public Amount(Currency currency, BigDecimal value) { this.currency = currency; this.value = value; } public Currency getCurrency() { return currency; } public BigDecimal getValue() { return value; } @Override public String toString() { return "Amount{" + "currency=" + currency + ", value=" + value + '}'; } }
3a6366fde7476b77dfad73812c37468eea28cba3
52fe175ab4cf4642b11eaae78a2a2f3279390b93
/src/Google_Leetcode/FoodItems.java
8e2693dfdcb68d45f083027fb785e32d9c64fcd9
[]
no_license
karthikbeepi/Interview_Preparation
4ea30204cc81fd1b89d3b153a0e3018472055765
a943fe5501d802678f31af39299de4c92f7412bb
refs/heads/master
2022-11-05T18:42:07.892761
2020-06-24T04:06:39
2020-06-24T04:06:39
220,839,301
0
0
null
null
null
null
UTF-8
Java
false
false
2,033
java
package Google_Leetcode; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Set; public class FoodItems { int noOfItems; HashMap<String, ArrayList<Integer>> products; HashMap<String, Integer> avgProductPrice; public FoodItems(int n) { noOfItems = n; products = new HashMap<String, ArrayList<Integer>>(); avgProductPrice = new HashMap<String, Integer>(); } public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int noOfCases = Integer.parseInt(br.readLine()); StringBuilder sb = new StringBuilder(); for(int i=0; i<noOfCases; i++) { FoodItems obj = new FoodItems(Integer.parseInt(br.readLine())); for(int j=0; j<obj.noOfItems; j++) { obj.getItems(br.readLine()); } sb.append("Case "+(i+1)+"\n"); sb.append(obj.printDetails()); } System.out.println(sb); } private String printDetails() { StringBuilder sb = new StringBuilder(); ArrayList<String> sortedKeys = new ArrayList<String>(); sortedKeys.addAll(products.keySet()); Collections.sort(sortedKeys); for(String s: sortedKeys) { sb.append(s+" "); for(int i: products.get(s)) sb.append(i+" "); sb.append(avgProductPrice.get(s)+"\n"); } return sb.toString(); } private void getItems(String line) { String productName = line.split(" ")[0]; int productVal = Integer.parseInt(line.split(" ")[1]); ArrayList<Integer> arrVal; if(!products.containsKey(productName)) { arrVal = new ArrayList<Integer>(); } else { arrVal = products.get(productName); } arrVal.add(productVal); products.put(productName, arrVal); float avg = (float) 0.0; for(int i: arrVal) { avg+= i; } avg/=arrVal.size(); avgProductPrice.put(productName, (int) Math.round(avg)); } }
d059a98a15b85fff863e0421549ef4b0905ecdb1
e5d9269646f276fd4c9cf110ae7ad6e660ad220a
/app/src/main/java/com/example/android/quizapp/MainActivity.java
826c9399667cb36158de411df84367d6791818ab
[]
no_license
erickibz/QuizApp
c8b6c9eafa845d0cf33ac96adcbc6905844bb900
659b64f1e32804c5ea9252a0e365613a36ecf678
refs/heads/master
2020-03-22T00:18:22.164162
2018-06-30T09:51:17
2018-06-30T09:51:17
139,236,560
0
0
null
null
null
null
UTF-8
Java
false
false
411
java
package com.example.android.quizapp; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.RadioButton; import android.widget.RadioGroup; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }
25fa62fc818f2e7ba72210309a4b1c078310f197
dc1f79b80db2287695fda7f6bcc672df04464c33
/boot-dubbo-consumer/src/main/java/com/zhenglei/dubbo/service/TestService.java
b9048511e80397776497528d6c37dcf27b3c5c9c
[]
no_license
2767131402/dubbo
7b9ed90e4319d638938eca23e5d0d97424f55ba7
8d89cf1fba3781f2c01088065615c67c644cc9de
refs/heads/master
2022-12-05T03:31:36.639267
2020-08-26T14:46:12
2020-08-26T14:46:12
290,143,766
0
0
null
null
null
null
UTF-8
Java
false
false
490
java
package com.zhenglei.dubbo.service; import com.zhenglei.dubbo.MyProviderService; import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.stereotype.Service; @Service public class TestService { //stub 注解方式 配置本地存根 @DubboReference(stub = "com.zhenglei.dubbo.sub.MyProviderServiceSub") private MyProviderService myProviderService; public String sayHello(String name){ return myProviderService.sayHello(name); } }
28779b4f386867c7d20314e65c95e36b1fb5aacf
40e7f2734676250b985cd18b344329cea8a7c42b
/instrumentation/java-http-client/testing/src/main/java/io/opentelemetry/instrumentation/httpclient/AbstractJavaHttpClientTest.java
c4fe8369caf296933c48880a2fafc6a568a97123
[ "Apache-2.0" ]
permissive
open-telemetry/opentelemetry-java-instrumentation
d6f375148715f8ddb2d4a987c0b042cb6badbfa2
b0a8bd4f47e55624fb3942e34b7a7051d075f2a5
refs/heads/main
2023-09-01T15:10:10.287883
2023-09-01T08:07:11
2023-09-01T08:07:11
210,933,087
1,349
689
Apache-2.0
2023-09-14T18:42:00
2019-09-25T20:19:14
Java
UTF-8
Java
false
false
3,643
java
/* * Copyright The OpenTelemetry Authors * SPDX-License-Identifier: Apache-2.0 */ package io.opentelemetry.instrumentation.httpclient; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpClientTest; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientResult; import io.opentelemetry.instrumentation.testing.junit.http.HttpClientTestOptions; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.junit.jupiter.api.BeforeAll; public abstract class AbstractJavaHttpClientTest extends AbstractHttpClientTest<HttpRequest> { private HttpClient client; @BeforeAll void setUp() { HttpClient httpClient = HttpClient.newBuilder() .version(HttpClient.Version.HTTP_1_1) .connectTimeout(CONNECTION_TIMEOUT) .followRedirects(HttpClient.Redirect.NORMAL) .build(); client = configureHttpClient(httpClient); } protected abstract HttpClient configureHttpClient(HttpClient httpClient); @Override public HttpRequest buildRequest(String method, URI uri, Map<String, String> headers) { HttpRequest.Builder requestBuilder = HttpRequest.newBuilder().uri(uri).method(method, HttpRequest.BodyPublishers.noBody()); headers.forEach(requestBuilder::header); if (uri.toString().contains("/read-timeout")) { requestBuilder.timeout(READ_TIMEOUT); } return requestBuilder.build(); } @Override public int sendRequest(HttpRequest request, String method, URI uri, Map<String, String> headers) throws IOException, InterruptedException { return client.send(request, HttpResponse.BodyHandlers.ofString()).statusCode(); } @Override public void sendRequestWithCallback( HttpRequest request, String method, URI uri, Map<String, String> headers, HttpClientResult httpClientResult) { client .sendAsync(request, HttpResponse.BodyHandlers.ofString()) .whenComplete( (response, throwable) -> { if (throwable == null) { httpClientResult.complete(response.statusCode()); } else if (throwable.getCause() != null) { httpClientResult.complete(throwable.getCause()); } else { httpClientResult.complete( new IllegalStateException("throwable.getCause() returned null", throwable)); } }); } @Override protected void configure(HttpClientTestOptions.Builder optionsBuilder) { optionsBuilder.disableTestCircularRedirects(); // TODO nested client span is not created, but context is still injected // which is not what the test expects optionsBuilder.disableTestWithClientParent(); optionsBuilder.setHttpAttributes( uri -> { Set<AttributeKey<?>> attributes = new HashSet<>(HttpClientTestOptions.DEFAULT_HTTP_ATTRIBUTES); // unopened port or non routable address; or timeout if ("http://localhost:61/".equals(uri.toString()) || "https://192.0.2.1/".equals(uri.toString()) || uri.toString().contains("/read-timeout")) { attributes.remove(SemanticAttributes.NET_PROTOCOL_NAME); attributes.remove(SemanticAttributes.NET_PROTOCOL_VERSION); } return attributes; }); } }
7a2f0acafb4e1735b05d691a9bba0447d4fb827f
a010f18a1d4d952933a8961159bfe72d3c1a72c9
/NettyRpc-server-1/src/main/java/com/zcl/nettyRpc/service/impl/GoodsServiceImpl.java
8ef9976f2ccf017cd21de2921adad8b66d983a61
[]
no_license
zcl1234/nettyRpc
4b35e9f9034bddacfb19d134389b86a769df3bcb
c03d5ea27336d210d795f7d1b8737004c15ea99b
refs/heads/master
2020-12-30T15:42:18.509107
2017-05-16T14:22:52
2017-05-16T14:22:52
91,167,025
0
0
null
null
null
null
UTF-8
Java
false
false
354
java
package com.zcl.nettyRpc.service.impl; import com.zcl.nettyRpc.Entity.Goods; import com.zcl.nettyRpc.serivce.GoodsService; /** * Created by 626hp on 2017/5/14. */ public class GoodsServiceImpl implements GoodsService { @Override public Goods getGoods(String title) { Goods goods=new Goods(title,1000); return goods; } }
452288f7459d97f21cd7fe83a21cccbaad766012
be16366efbf614e62e66362a33ac8aae450b956c
/src/main/java/altea/pokemonshop/contoller/ShopController.java
b4b0228538dc772c3dfac199a2de41147a065f9b
[]
no_license
ALTEA-2018/shop-api-selleniackn
4b6082304db7d57b7b53f34cb881791179f3b5e4
db1be023b7036fbf0f7eb2ebf9f66667ede619a7
refs/heads/master
2020-06-12T01:27:24.359070
2019-07-05T17:13:44
2019-07-05T17:13:44
194,151,671
0
0
null
null
null
null
UTF-8
Java
false
false
2,723
java
package altea.pokemonshop.contoller; import altea.pokemonshop.bo.Item; import altea.pokemonshop.bo.Trainer; import altea.pokemonshop.service.ItemService; import altea.pokemonshop.service.TrainerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.servlet.ModelAndView; import java.util.HashMap; import java.util.List; import java.util.Map; @Controller public class ShopController { private TrainerService trainerService; private ItemService itemService; @GetMapping(value = "/") public ModelAndView shop() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); UserDetails principal = (UserDetails) authentication.getPrincipal(); Map<String, Object> stringObjectMap = new HashMap<>(); Trainer trainer = this.trainerService.findTrainerByName(principal.getUsername()); List<Item> items = this.itemService.findAllItems(); stringObjectMap.put("trainer", trainer); stringObjectMap.put("items", items); stringObjectMap.put("message", "Welcome to the Poke Shop !"); return new ModelAndView("shop", stringObjectMap); } @PostMapping(value = "/addItem") public ModelAndView addNewItem( int id){ Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); UserDetails principal = (UserDetails) authentication.getPrincipal(); Map<String, Object> stringObjectMap = new HashMap<>(); Trainer trainer = this.trainerService.findTrainerByName(principal.getUsername()); boolean added = this.trainerService.addItem(id, trainer.getName()); List<Item> items = this.itemService.findAllItems(); if (added) { stringObjectMap.put("message", "This item is yours now !!!"); } else { stringObjectMap.put("message", "You don't have enough Pokedollars"); } stringObjectMap.put("trainer", trainer); stringObjectMap.put("items", items); return new ModelAndView("shop", stringObjectMap); } @Autowired public void setTrainerService(TrainerService trainerService) { this.trainerService = trainerService; } @Autowired public void setItemService(ItemService itemService) { this.itemService = itemService; } }
bf3ac5aa8b4df27e7f9373f60f3548454afd04f4
624743174728c1ed46d5ef37b5557ed210308c22
/app/src/main/java/app/jiyi/com/mjoke/utilview/LoadMoreListView.java
d2bb0c9c05413110fe33481095d255be09ec9d7c
[]
no_license
jiyiren/mjoke
e891a9af3c3ba361820111c07e925f153bd97ed3
1b8e483e323fc9933413d4f32003a603eb70188e
refs/heads/master
2021-01-21T14:09:20.151771
2018-12-03T05:19:25
2018-12-03T05:19:25
42,521,482
56
10
null
null
null
null
UTF-8
Java
false
false
2,358
java
package app.jiyi.com.mjoke.utilview; import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.AbsListView; import android.widget.ListView; import app.jiyi.com.mjoke.R; /** * Created by JIYI on 2015/8/31. */ public class LoadMoreListView extends ListView implements AbsListView.OnScrollListener{ private int totalItem; private int lastItem; private View footer; private LayoutInflater layoutInflater; private boolean isloading=false; private OnLoadMore onLoadMore; public LoadMoreListView(Context context) { super(context); initView(context); } public LoadMoreListView(Context context, AttributeSet attrs) { super(context, attrs); initView(context); } public LoadMoreListView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); initView(context); } private void initView(Context context) { layoutInflater=LayoutInflater.from(context); footer = layoutInflater.inflate(R.layout.listview_booter, null); footer.setVisibility(View.GONE); this.addFooterView(footer); this.setOnScrollListener(this); } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if ((this.totalItem == lastItem) && (scrollState == SCROLL_STATE_TOUCH_SCROLL)) { // Log.v("isLoading", "yes"); if (!isloading) { if(onLoadMore!=null) { isloading = true; footer.setVisibility(View.VISIBLE); onLoadMore.loadMore(); } } } } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { this.lastItem=firstVisibleItem+visibleItemCount; this.totalItem=totalItemCount; } public void setLoadMoreListen(OnLoadMore onLoadMore){ this.onLoadMore = onLoadMore; } /** * 加载完成调用此方法 */ public void onLoadComplete(){ footer.setVisibility(View.GONE); isloading = false; } public interface OnLoadMore{ public void loadMore(); } }
98f791ef2795e928086f79407fe1b7c591e6fd53
8b9190a8c5855d5753eb8ba7003e1db875f5d28f
/sources/com/google/android/gms/common/util/DefaultClock.java
3568b89067bfaae77c087ab6ef48409351cd7251
[]
no_license
stevehav/iowa-caucus-app
6aeb7de7487bd800f69cb0b51cc901f79bd4666b
e3c7eb39de0be6bbfa8b6b063aaa85dcbcee9044
refs/heads/master
2020-12-29T10:25:28.354117
2020-02-05T23:15:52
2020-02-05T23:15:52
238,565,283
21
3
null
null
null
null
UTF-8
Java
false
false
733
java
package com.google.android.gms.common.util; import android.os.SystemClock; import com.google.android.gms.common.annotation.KeepForSdk; @KeepForSdk public class DefaultClock implements Clock { private static final DefaultClock zzgm = new DefaultClock(); @KeepForSdk public static Clock getInstance() { return zzgm; } public long currentTimeMillis() { return System.currentTimeMillis(); } public long elapsedRealtime() { return SystemClock.elapsedRealtime(); } public long nanoTime() { return System.nanoTime(); } public long currentThreadTimeMillis() { return SystemClock.currentThreadTimeMillis(); } private DefaultClock() { } }
f0d51b7e11a5c9f9da95912cd9feedd9aa908a8e
17453bea5c26ff83d226e08aad47dfc9f16562af
/src/com/whatsahandle/bountyhunter/SetBounty.java
cbbefc16334751c92dcf031e0fc8511f866b3de8
[]
no_license
whats-a-handle/minecraft-bounty-hunter
ca8d6d6f3996f115487ad805f1a0e0f68960a0b5
945e9e153ef9f94c579204f06c4e69d68020eb7f
refs/heads/master
2020-03-29T11:06:11.081529
2018-09-22T06:54:34
2018-09-22T06:54:34
149,836,032
0
0
null
null
null
null
UTF-8
Java
false
false
1,422
java
package com.whatsahandle.bountyhunter; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class SetBounty implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(sender instanceof Player ) { DatabaseConnection dbConnection = new DatabaseConnection(); dbConnection.authenticate(); dbConnection.createTable(); String targetPlayer = ""; int bountyAmount = 0; if(args[0] == null) { sender.sendMessage("Sorry, you must enter a target player name."); return false; } else { targetPlayer = args[0]; } if(args[1] != null && BountyValidator.isAdminBountyValid(args[1])) { bountyAmount = Integer.valueOf(args[1]); bountyAmount = Integer.valueOf(args[1]); dbConnection.setPlayerBounty(targetPlayer, bountyAmount); sender.sendMessage("You\'ve set a bounty of $" + bountyAmount + " on " + targetPlayer); return true; } else { sender.sendMessage("Sorry, enter a bounty amount greater than or equal to 0"); return false; } } return false; } }
fc7d33469456330f0535df53eb730d6937e894e2
1b3b3a31ebc262d616b0c1d1fd8ea57e92c803bb
/src/com/itheima/domain/Book.java
a08fb723ef40b20a3cbc7c14c0857f57464b6540
[]
no_license
remix7/BookStore
a1a56cb73752098cd125e0f4a4dd47b2e45418be
ca2e19e3a03761c14b73c45c72d1ab7032b25776
refs/heads/master
2021-01-22T23:06:02.341710
2016-02-04T10:05:56
2016-02-04T10:05:56
null
0
0
null
null
null
null
GB18030
Java
false
false
1,743
java
package com.itheima.domain; import java.io.Serializable; public class Book implements Serializable { private String id; private String name; private String author; private float price; private String imageName;//与表单不一样哦 private String description; private String categoryid; public Book(){ super(); } public Book(String id, String name, String author, float price, String imageName, String description, String categoryid) { super(); this.id = id; this.name = name; this.author = author; this.price = price; this.imageName = imageName; this.description = description; this.categoryid = categoryid; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public float getPrice() { return price; } public void setPrice(float price) { this.price = price; } public String getImageName() { return imageName; } public void setImageName(String imageName) { this.imageName = imageName; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getCategoryid() { return categoryid; } public void setCategoryid(String categoryid) { this.categoryid = categoryid; } @Override public String toString() { return "Book [id=" + id + ", name=" + name + ", author=" + author + ", price=" + price + ", imageName=" + imageName + ", description=" + description + ", categoryid=" + categoryid + "]"; } }
c2f222e74344f2376045c2c0732755b6e354ace9
e4ef8e6dfff61c0a85aa2958c7963a5d1dec60c1
/mano/src/main/java/mano/util/Pool.java
229da987b13ab2383daae7623047298193ec74e9
[]
no_license
wlfs/mano
e94751d2635a386429383c4d387966fa9f6478ae
381df03a50275d0de8f9425b8e283dfe42bafef3
refs/heads/master
2020-12-24T10:15:59.441943
2014-09-05T01:45:04
2014-09-05T01:45:04
null
0
0
null
null
null
null
UTF-8
Java
false
false
2,265
java
/* * Copyright (C) 2014 The MANO Authors. * All rights reserved. Use is subject to license terms. * * See more http://mano.diosay.com/ * */ package mano.util; import java.lang.ref.PhantomReference; import java.lang.ref.ReferenceQueue; import java.util.Queue; import java.util.concurrent.LinkedBlockingQueue; import mano.Resettable; /** * * @author jun <[email protected]> * @param <T> */ public class Pool<T> { private final Queue<T> items = new LinkedBlockingQueue<>(); private ObjectFactory<T> _factory; private int count; private int keepIdelLimit; protected Pool() { } public Pool(ObjectFactory<T> factory) { _factory = factory; } public Pool(ObjectFactory<T> factory, int keepIdels) { _factory = factory; keepIdelLimit = keepIdels; } protected T create() { if (_factory == null) { throw new IllegalArgumentException(); } return _factory.create(); } public synchronized T get() { if (count < keepIdelLimit) { return create(); } T result = items.poll(); if (result == null) { result = create(); } else { count--; } return result; } public synchronized void put(T item) { if (item == null) { return; } count++; if (item instanceof Resettable) { ((Resettable) item).reset(); } items.offer(item); } public int count() { return count; } public synchronized void clear() { count = 0; items.clear(); } public static void mainsssss(String... args) { ReferenceQueue rq = new ReferenceQueue(); PhantomReference wr = new PhantomReference("abc", rq); System.gc(); try { Thread.sleep(1000); } catch (InterruptedException ex) { } System.gc(); try { Thread.sleep(1000); } catch (InterruptedException ex) { } System.gc(); System.out.println(wr.get()); System.out.println(rq.poll()); } }
cef42d87594d559a759d633da00ba5c902fe8134
6a1eeda00c2932c0a43bf5dd0fc867f565c97a01
/scconsumer-dept-80/src/main/java/wrx/sc/configclient3355/SCConsumerDept80Application.java
98fda50c08b43885e958bf5c0e9e6f13e9524a3b
[]
no_license
wuruixiong/SpringCloudDemo
0eb012c8d78e3463bda004f93b69b3a1fbf8c55b
840dd5317264e278876e4eb251652310d4a4feff
refs/heads/master
2022-11-28T00:23:52.874957
2020-08-04T02:44:32
2020-08-04T02:44:32
282,945,173
0
0
null
null
null
null
UTF-8
Java
false
false
698
java
package wrx.sc.configclient3355; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.ribbon.RibbonClient; import wrx.sc.configclient3355.myrule.KuangRule; @SpringBootApplication @EnableEurekaClient //在微服务启动的时候就能去加载我们自定义Ribbon类 @RibbonClient(name = "SPRINGCLOUD-PROVIDER-DEPT",configuration = KuangRule.class) public class SCConsumerDept80Application { public static void main(String[] args) { SpringApplication.run(SCConsumerDept80Application.class, args); } }
ebfe8816450293df83932d2e99c80ee54fd2fca7
24564796b4a300ad3e52c46730385d47358c63e3
/src/main/java/com/prarui/coment/Interceptor/HelloInterceptor.java
ff98bec71c5bf066c2c81652c42768ea80c04828
[]
no_license
ThoughtRain/coment
d0eb037e184fbad7a69bac6e765f02c8b45fc011
0210263c0429c6914e50967a71508b6037453b91
refs/heads/master
2022-05-29T09:11:03.952820
2019-09-03T01:39:20
2019-09-03T01:39:20
201,191,753
0
0
null
2022-05-20T21:05:05
2019-08-08T06:22:18
Java
UTF-8
Java
false
false
1,566
java
package com.prarui.coment.Interceptor; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class HelloInterceptor extends HandlerInterceptorAdapter { /** * This implementation always returns {@code true}. */ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { System.out.println("preHandle---->execute"); return true; } /** * This implementation is empty. */ @Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)throws Exception { System.out.println("postHandle--->execute"); } /** * This implementation is empty. */ @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)throws Exception { System.out.println("afterCompletion--->"); } /** * This implementation is empty. */ @Override public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler)throws Exception { System.out.println("afterConcurrentHandlingStarted--->"); } }
046b3e6075c94aa68f154cc3b3b1cd483cbeae70
ec5709bfe427b7efe1599ab0e1360173c5f609a3
/app-leetcode/src/main/java/com/guce/Permute.java
a64ae66fe6f4a7b4034e5008eb70671aea4ee67e
[]
no_license
werwolfGu/JHodgepodge
b941d8ff28d0a4a7fcc46f59fcd057d62b3d9f9c
14b594970f5ca2bf842ab5094ef9d443665309ce
refs/heads/master
2022-12-22T18:11:40.932246
2022-05-15T07:25:18
2022-05-15T07:25:18
147,911,191
8
3
null
2022-12-10T05:53:09
2018-09-08T07:18:17
Java
UTF-8
Java
false
false
1,970
java
package com.guce; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; import java.util.LinkedList; import java.util.List; /** * @Author chengen.gce * @DATE 2020/4/25 5:23 下午 * https://leetcode-cn.com/problems/permutations/submissions/ * <p> * 全排列 */ public class Permute { public static List<List<Integer>> solution(int[] nums) { List<List<Integer>> res = new ArrayList<>(); LinkedList list = new LinkedList(); backtrace(nums, res, list); return res; } public static void backtrace(int[] nums, List<List<Integer>> res, LinkedList<Integer> list) { if (nums.length == list.size()) { res.add(new ArrayList<>(list)); return; } for (int i = 0; i < nums.length; i++) { if (list.contains(nums[i])) { continue; } list.add(nums[i]); backtrace(nums, res, list); list.removeLast(); } } public static List<List<Integer>> solution2(int[] nums) { List<List<Integer>> res = new ArrayList<>(); boolean used[] = new boolean[nums.length]; Deque<Integer> path = new ArrayDeque<>(); backtrace(nums, used, path, res); return res; } public static void backtrace(int nums[], boolean used[], Deque<Integer> path, List<List<Integer>> res) { if (nums.length == path.size()) { res.add(new ArrayList<>(path)); } for (int i = 0; i < nums.length; i++) { if (used[i]) { continue; } used[i] = true; path.addLast(nums[i]); backtrace(nums, used, path, res); used[i] = false; path.removeLast(); } } public static void main(String[] args) { System.out.println(solution(new int[]{1, 2, 3})); System.out.println(solution2(new int[]{1, 2, 3})); } }
124478b0e7f18f98c8a3447230ff7f2b0dd39d86
fbf27d453d933352a2c8ef76e0445f59e6b5d304
/server/src/com/fy/engineserver/message/JIAZU_RELEVANT_DES_REQ.java
97e57f021fffc9e68daf3bf4965aa8008babccea
[]
no_license
JoyPanda/wangxian_server
0996a03d86fa12a5a884a4c792100b04980d3445
d4a526ecb29dc1babffaf607859b2ed6947480bb
refs/heads/main
2023-06-29T05:33:57.988077
2021-04-06T07:29:03
2021-04-06T07:29:03
null
0
0
null
null
null
null
UTF-8
Java
false
false
4,078
java
package com.fy.engineserver.message; import com.xuanzhi.tools.transport.*; import java.nio.ByteBuffer; /** * 网络数据包,此数据包是由MessageComplier自动生成,请不要手动修改。<br> * 版本号:null<br> * 请求家族界面相关描述<br> * 数据包的格式如下:<br><br> * <table border="0" cellpadding="0" cellspacing="1" width="100%" bgcolor="#000000" align="center"> * <tr bgcolor="#00FFFF" align="center"><td>字段名</td><td>数据类型</td><td>长度(字节数)</td><td>说明</td></tr> * <tr bgcolor="#FFFFFF" align="center"><td>length</td><td>int</td><td>getNumOfByteForMessageLength()个字节</td><td>包的整体长度,包头的一部分</td></tr> * <tr bgcolor="#FAFAFA" align="center"><td>type</td><td>int</td><td>4个字节</td><td>包的类型,包头的一部分</td></tr> * <tr bgcolor="#FFFFFF" align="center"><td>seqNum</td><td>int</td><td>4个字节</td><td>包的序列号,包头的一部分</td></tr> * <tr bgcolor="#FAFAFA" align="center"><td>windowId</td><td>int</td><td>4个字节</td><td>配置的长度</td></tr> * <tr bgcolor="#FFFFFF" align="center"><td>targetName.length</td><td>short</td><td>2个字节</td><td>字符串实际长度</td></tr> * <tr bgcolor="#FAFAFA" align="center"><td>targetName</td><td>String</td><td>targetName.length</td><td>字符串对应的byte数组</td></tr> * </table> */ public class JIAZU_RELEVANT_DES_REQ implements RequestMessage{ static GameMessageFactory mf = GameMessageFactory.getInstance(); long seqNum; int windowId; String targetName; public JIAZU_RELEVANT_DES_REQ(){ } public JIAZU_RELEVANT_DES_REQ(long seqNum,int windowId,String targetName){ this.seqNum = seqNum; this.windowId = windowId; this.targetName = targetName; } public JIAZU_RELEVANT_DES_REQ(long seqNum,byte[] content,int offset,int size) throws Exception{ this.seqNum = seqNum; windowId = (int)mf.byteArrayToNumber(content,offset,4); offset += 4; int len = 0; len = (int)mf.byteArrayToNumber(content,offset,2); offset += 2; if(len < 0 || len > 16384) throw new Exception("string length ["+len+"] big than the max length [16384]"); targetName = new String(content,offset,len); offset += len; } public int getType() { return 0x00FF0064; } public String getTypeDescription() { return "JIAZU_RELEVANT_DES_REQ"; } public String getSequenceNumAsString() { return String.valueOf(seqNum); } public long getSequnceNum(){ return seqNum; } private int packet_length = 0; public int getLength() { if(packet_length > 0) return packet_length; int len = mf.getNumOfByteForMessageLength() + 4 + 4; len += 4; len += 2; len +=targetName.getBytes().length; packet_length = len; return len; } public int writeTo(ByteBuffer buffer) { int messageLength = getLength(); if(buffer.remaining() < messageLength) return 0; int oldPos = buffer.position(); buffer.mark(); try{ buffer.put(mf.numberToByteArray(messageLength,mf.getNumOfByteForMessageLength())); buffer.putInt(getType()); buffer.putInt((int)seqNum); buffer.putInt(windowId); byte[] tmpBytes1; tmpBytes1 = targetName.getBytes(); buffer.putShort((short)tmpBytes1.length); buffer.put(tmpBytes1); }catch(Exception e){ e.printStackTrace(); buffer.reset(); throw new RuntimeException("in writeTo method catch exception :",e); } int newPos = buffer.position(); buffer.position(oldPos); buffer.put(mf.numberToByteArray(newPos-oldPos,mf.getNumOfByteForMessageLength())); buffer.position(newPos); return newPos-oldPos; } /** * 获取属性: * 窗口id,用以区分 1:家族面板 */ public int getWindowId(){ return windowId; } /** * 设置属性: * 窗口id,用以区分 1:家族面板 */ public void setWindowId(int windowId){ this.windowId = windowId; } /** * 获取属性: * 按钮名 */ public String getTargetName(){ return targetName; } /** * 设置属性: * 按钮名 */ public void setTargetName(String targetName){ this.targetName = targetName; } }
2c5f6a5f748e491da08e2df8e84cf769fb9ded99
04d8edf348d197b28aba1ae74591ce2d51f83d05
/src/main/java/com/smarthire/main/service/EmployerServiceImpl.java
3be56141944c78051f3e1fd5cf1ffbe8a1891ad1
[]
no_license
xanderLum/SMARTHire
0ccf2d9b4f3c20e13cae05e5a135dd672574fe0f
a23598392f67a34962b4e77dd69760d7016587fa
refs/heads/master
2022-12-28T13:39:48.355151
2019-10-24T18:42:13
2019-10-24T18:42:13
190,709,879
3
1
null
2022-12-16T04:32:57
2019-06-07T08:13:51
Java
UTF-8
Java
false
false
3,190
java
package com.smarthire.main.service; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import com.smarthire.main.dao.EmployerDao; import com.smarthire.main.models.Employer; @Service public class EmployerServiceImpl implements EmployerService{ @Autowired EmployerDao employerDao; @Override public ResponseEntity<Employer> create(Employer emp) { try{ employerDao.create(emp); System.out.println("Success in Employer Service Impl create"); return new ResponseEntity<Employer>(emp, HttpStatus.OK); } catch(Exception e){ System.out.println("Catch in Employer Service Impl create"); return new ResponseEntity<Employer>(HttpStatus.BAD_REQUEST); } } @Override public ResponseEntity<Employer> update(Employer emp) { try{ employerDao.update(emp); System.out.println("Success in Employer Service Impl update"); return new ResponseEntity<Employer>(emp, HttpStatus.OK); } catch(Exception e){ System.out.println("Catch in Employer Service Impl update"); return new ResponseEntity<Employer>(HttpStatus.BAD_REQUEST); } } @Override public ResponseEntity<Employer> delete(Long id) { try{ Employer emp = employerDao.delete(id); System.out.println("Success in Employer Service Impl delete"); return new ResponseEntity<Employer>(emp, HttpStatus.OK); } catch(Exception e){ System.out.println("Catch in Employer Service Impl delete"); return new ResponseEntity<Employer>(HttpStatus.BAD_REQUEST); } } @Override public ResponseEntity<List<Employer>> getList() { try{ List<Employer> lemp = employerDao.getList(); System.out.println("Success in Employer Service Impl getList"); return new ResponseEntity<List<Employer>>(lemp, HttpStatus.OK); } catch(Exception e){ System.out.println("Catch in Employer Service Impl getList"); return new ResponseEntity<List<Employer>>(HttpStatus.BAD_REQUEST); } } @Override public ResponseEntity<Employer> authenticate(String username, String password) { Employer flag = new Employer(); try{ flag = employerDao.authenticate(username, password); System.out.println("Success in Employer Service Impl "); if(flag != null){ System.out.println("There is a record Employer authenticate"); return new ResponseEntity<Employer>(flag, HttpStatus.OK); } else{ System.out.println("There is NO record Employer authenticate"); return new ResponseEntity<Employer>(HttpStatus.BAD_REQUEST); } } catch(Exception e){ System.out.println("Catch in Employer Service Impl authenticate"); return new ResponseEntity<Employer>(HttpStatus.BAD_REQUEST); } } @Override public ResponseEntity<Employer> read(String username) { try{ Employer emp = employerDao.read(username); System.out.println("Success in Employer Service Impl read"); return new ResponseEntity<Employer>(emp, HttpStatus.OK); } catch(Exception e){ System.out.println("Catch in Employer Service Impl read"); return new ResponseEntity<Employer>(HttpStatus.BAD_REQUEST); } } }
ea63041f96369104ed7336934bbec8e558862f1d
c95034995001f99857f8c3700be1296eba62a37c
/team3/src/test/java/com/codefactory/team3/Team3ApplicationTests.java
c32305b520fb1543fea4d8215db615a53b250e4f
[]
no_license
CodeFactoryWien/WF-Java-03
fee54a6b5d6d2f30a712929ef4734e67818423b8
ccc5e47884a7b1c4ad6c6572f30b9c8d05c229c8
refs/heads/master
2020-12-08T18:01:49.324568
2020-01-24T07:52:41
2020-01-24T07:52:41
233,054,918
1
0
null
null
null
null
UTF-8
Java
false
false
212
java
package com.codefactory.team3; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class Team3ApplicationTests { @Test void contextLoads() { } }
41a8f601beeefb13a8ff7b308d942c4903a05a02
0d00d4919b2dd466d07e48f0556a2fbf18b144af
/PathSum2.java
db877d6a0cd9a6a42c86ab965ad8a230a2ea8d76
[]
no_license
LokeswariU/Trees-3
5f21fac70c5c36324c5334dfc25359f2fe06c70b
e3e09e111b57bd5cac6835c1caac05368c163f54
refs/heads/master
2023-03-21T11:04:57.654756
2021-03-10T14:17:13
2021-03-10T14:17:13
346,376,536
0
0
null
null
null
null
UTF-8
Java
false
false
1,640
java
// Time Complexity : O(n^2) // Space Complexity : O(n) height of tree for recursion stack // Did this code successfully run on Leetcode : Yes // Any problem you faced while coding this : No // Your code here along with comments explaining your approach /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } * TreeNode(int val, TreeNode left, TreeNode right) { * this.val = val; * this.left = left; * this.right = right; * } * } */ class Solution { List<List<Integer>> result = new ArrayList<>(); public List<List<Integer>> pathSum(TreeNode root, int targetSum) { sum(root,targetSum,0, new ArrayList<>()); return result; } // Used recursion to traverse from root to leaf node and temp sum to add the node values in a path // Also add the node values of the path in a temporary list. If the temporary sum == target sum, then add the temporary list to global list // Used backtracking to remove the elements from temporary list and traverse in another right direction public void sum(TreeNode root, int targetSum, int temp, List<Integer> list){ if(root == null) return; temp += root.val; list.add(root.val); if(root.left == null && root.right == null && targetSum == temp) result.add(new ArrayList(list)); if(root.left != null) sum(root.left,targetSum,temp,list); if(root.right != null) sum(root.right,targetSum,temp,list); list.remove(list.size()-1); } }
08d8fa3e684ebd952347392d725b50899ed9762b
dd4e5a15965ec40bfcf6d0fbb773bed4d9e87d2a
/src/main/java/com/fastdata/algorithm/medium/array/PartitionArrayIntoDisjointIntervals.java
af3f4e841cf7f2e4d781b37652f14b12eef7709f
[]
no_license
lucky0604/leetcode-practice
6d27719f5e771df75f4aba9c74141913858045f1
fc4a22ea22dbe82877f45770af8461f1b2e618af
refs/heads/main
2023-08-15T07:26:36.082453
2021-09-20T04:45:37
2021-09-20T04:45:37
334,917,997
0
0
null
null
null
null
UTF-8
Java
false
false
860
java
package com.fastdata.algorithm.medium.array; /** * @Author: lucky * @License: (C) Copyright * @Contact: [email protected] * @Date: 2021-06-07 10:00 AM * @Version: 1.0 * @description: https://leetcode.com/problems/partition-array-into-disjoint-intervals/ **/ // TODO: to be understand public class PartitionArrayIntoDisjointIntervals { public int partitionDisjoint(int[] nums) { // init the current max and next max value int currentMax = nums[0]; int nextMax = nums[0]; int ret = 0; for (int i = 1; i < nums.length; i ++) { int currentVal = nums[i]; nextMax = Math.max(currentVal, nextMax); if (currentVal < currentMax) { currentMax = nextMax; ret = i; } } return ret + 1; } }
0117105663f07264fcb5384a5c68b4f8c8dbf63a
585fd0a0d83b4eeaf47e4f0cadacaff507d2154d
/codeworld-cloud-order/src/main/java/com/codeworld/fc/order/client/MerchantClient.java
6a538747c8b2c74e9d66cde8e4306f932081478f
[]
no_license
sengeiou/codeworld-cloud-shop-api
accce2ca5686dcf2dc0c0bc65c4c1eb6a467a8e9
2297f0e97d1327a9f4a48a341a08ea3a58905a62
refs/heads/master
2023-02-16T05:51:21.778190
2021-01-15T09:48:56
2021-01-15T09:48:56
null
0
0
null
null
null
null
UTF-8
Java
false
false
690
java
package com.codeworld.fc.order.client; import com.codeworld.fc.common.response.FCResponse; import com.codeworld.fc.order.domain.MerchantResponse; import io.swagger.annotations.ApiOperation; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; @FeignClient(name = "codeworld-cloud-merchant") public interface MerchantClient { @PostMapping("/codeworld-merchant/get-merchant-number-name-id") @ApiOperation("根据商户id获取商户号和名称") FCResponse<MerchantResponse> getMerchantNumberAndNameById(@RequestParam("merchantId") Long merchantId); }
561e5821e8e42be9a32da2d3e0b17fcb0c18b8aa
e4f472fd90b837bc490dcdffc367fa7de4c97610
/generated/src/test/java/test/pack/data/greenvine/entity/test/BugJpaIntegrationTest.java
888e65db22b80e3090ef69cac4a7b7bba2eac7b0
[ "Apache-2.0" ]
permissive
pdaniel/greenvine
07ff45085625887dd0a89fada859a50e153a2e62
15d2c9797d4e09ba43e74d733cf9880389396cfc
refs/heads/master
2020-12-26T01:40:03.679884
2012-11-22T19:42:08
2012-11-22T19:42:08
null
0
0
null
null
null
null
UTF-8
Java
false
false
3,792
java
package test.pack.data.greenvine.entity.test; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.Query; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.unitils.UnitilsJUnit4TestClassRunner; import org.unitils.dbunit.annotation.DataSet; import org.unitils.dbunit.annotation.ExpectedDataSet; import org.unitils.orm.jpa.annotation.JpaEntityManagerFactory; import test.pack.data.greenvine.entity.test.Bug; import test.pack.data.greenvine.entity.test.BugTestUtils; import test.pack.data.greenvine.entity.test.User; import test.pack.data.greenvine.entity.test.UserTestUtils; @JpaEntityManagerFactory(persistenceUnit = "greenvine") @RunWith(UnitilsJUnit4TestClassRunner.class) public class BugJpaIntegrationTest { @PersistenceContext EntityManager entityManager; @Test @DataSet("BugBeforeCreateDataSet.xml") @ExpectedDataSet("BugAfterCreateDataSet.xml") public void testCreateBug() throws Exception { // Create new entity Bug create = new Bug(); // Set identity create.setBugId(Integer.valueOf(1)); // Populate simple properties create.setDescription("s"); create.setOpen(Boolean.TRUE); create.setTitle("s"); // Populate dependencies User reporter = (User)entityManager.getReference(User.class, UserTestUtils.getDefaultIdentity()); create.setReporter(reporter); User owner = (User)entityManager.getReference(User.class, UserTestUtils.getDefaultIdentity()); create.setOwner(owner); // Create in database entityManager.persist(create); } @Test @DataSet("BugBeforeUpdateDataSet.xml") @ExpectedDataSet("BugAfterUpdateDataSet.xml") public void testUpdateBug() throws Exception { // Load entity and modify Bug result = (Bug)entityManager.find(Bug.class, BugTestUtils.getDefaultIdentity()); // Set simple properties result.setDescription("t"); result.setOpen(Boolean.FALSE); result.setTitle("t"); // Update entityManager.merge(result); } @Test @DataSet("BugBeforeDeleteDataSet.xml") @ExpectedDataSet("BugAfterDeleteDataSet.xml") public void testRemoveBug() throws Exception { // Delete Bug result = (Bug)entityManager.find(Bug.class, BugTestUtils.getDefaultIdentity()); entityManager.remove(result); } @Test @DataSet("BugFindAllDataSet.xml") @SuppressWarnings("unchecked") public void testFindAllBug() throws Exception { // Create query Query query = entityManager.createQuery("from test.Bug"); // Get results List<Bug> results = query.getResultList(); Assert.assertNotNull(results); Assert.assertEquals(Integer.valueOf(100), Integer.valueOf(results.size())); } @Test @DataSet("BugFindDataSet.xml") public void testFindBugByIdentity() throws Exception { // Get object Bug result = (Bug)entityManager.find(Bug.class, BugTestUtils.getDefaultIdentity()); // Test result Assert.assertNotNull(result); // Test properties Assert.assertEquals("s", result.getDescription()); Assert.assertEquals(Boolean.TRUE, result.getOpen()); Assert.assertEquals("s", result.getTitle()); } }
c77e267d46947ebf498a981e0a407ca90e5cd7ec
c5196e5b4403f1d807f3be3ad94a7a8d6269d66a
/src/main/java/me/perol/blog/service/RedisService.java
bebb99d9208d62b50a68bc03d32ad3a780fdcc2e
[]
no_license
Notsfsssf/neo-back-end
b52ce3a70586a4a950136e51a9df48a4c5f77857
5c4b8cd56e96cc240d7200a4c8c1c8e42130a4f6
refs/heads/master
2021-07-23T11:04:19.923998
2020-07-29T14:38:13
2020-07-29T14:38:13
202,300,173
2
0
null
null
null
null
UTF-8
Java
false
false
329
java
package me.perol.blog.service; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; @Service public class RedisService { @Cacheable(value = "token", condition = "#age!=1") public String getit(int age) { return String.valueOf(System.currentTimeMillis()); } }
a990ac133a7dc8d722ee88fac6bcb433ff01a70c
cd253cf36e5ae02453adadbc144438ef6b047bd6
/src/main/java/levantuan/quanlykaraoke/dto/PhongDTO.java
85ff426b9ffe7e9402a1c31c53b4514253f9f952
[]
no_license
phuongjsp/QLKaraoke
0c645b1c77d9d2af29ed7fd09e0573cb78507df5
0ae030015e1530deb00f89f28a0b3d7834db220e
refs/heads/master
2022-07-01T02:22:48.195984
2020-07-02T05:24:43
2020-07-02T05:24:43
184,918,522
0
2
null
2020-07-02T05:24:44
2019-05-04T16:23:50
JavaScript
UTF-8
Java
false
false
1,237
java
package levantuan.quanlykaraoke.dto; import levantuan.quanlykaraoke.entities.Phong; import levantuan.quanlykaraoke.entities.ChiTietVatTu; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import java.util.List; @AllArgsConstructor @NoArgsConstructor @Data public class PhongDTO { private long id; private String maPhong; private int tinhTrangPhong; private Long idLoaiPhong; private String tenLoaiPhong; private int giaTrenGio; public PhongDTO(Phong phong) { this.id = phong.getId(); this.maPhong = phong.getMaPhong(); this.giaTrenGio = phong.getLoaiPhong().getTienPhongTrenGio(); this.tinhTrangPhong = phong.getTinhTrangPhong(); this.idLoaiPhong = phong.getLoaiPhong().getId(); this.tenLoaiPhong = phong.getLoaiPhong().getLoaiPhong(); } public void setPhong(Phong phong) { this.id = phong.getId(); this.maPhong = phong.getMaPhong(); this.tinhTrangPhong = phong.getTinhTrangPhong(); this.idLoaiPhong = phong.getLoaiPhong().getId(); this.tenLoaiPhong = phong.getLoaiPhong().getLoaiPhong(); } List<ChiTietVatTu> vatTus; List<UpdatePhongDTO> updatePhongDTOS; }
aa52dedc88008e65196ee072463586b817136ed2
8d816548fa2fcf3ef501ca3fc379266333c729c6
/app/src/main/java/com/lalbhaibrokers/mobilepolicing/DocumentVerification.java
d0523bab6bb7ae6de8de166593e3d82a16b76f05
[]
no_license
hetsukhwani/MobilePolicing
418e0f2616c75d96d9cfa1f1e935e2f287cf2cb1
ecdba2b226b520f0daed1651c2311b0a6155813c
refs/heads/master
2023-03-02T18:21:44.707182
2021-02-16T07:13:34
2021-02-16T07:13:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
371
java
package com.lalbhaibrokers.mobilepolicing; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class DocumentVerification extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_document_verification); } }
8105ba813cafa7f09db86d05ce481e2678badca3
77cf3c4de6601eca954829868c4a9a0ffd94d8e6
/src/main/java/com/index/service/AdminService.java
04539c6c9a10919b659d759dbf5bd9e0d1931139
[]
no_license
zengxihong/PersonalProject.index
b4d3b96fa5dde18e2131bd14276993fd957765fd
2048c1a1614d650d700884e70ab58e573c20ae30
refs/heads/master
2021-01-23T16:07:07.255803
2017-06-04T02:02:55
2017-06-04T02:02:55
93,284,393
3
1
null
null
null
null
UTF-8
Java
false
false
263
java
package com.index.service; import com.index.po.Admin; /** * Created by Administrator on 2017/5/26. */ public interface AdminService { public Admin selectAdminById(Integer id) throws Exception; public Admin adminLogin(Admin admin) throws Exception; }
8d7e28773da434b6b97961d650e96eb355e14841
ea2aa36a0aa5858d31d593b08baa7ab7394276b0
/src/regras/AndarNaDiagonal.java
aba67df1d414f281c2b7d793c534db77abb8eb69
[]
no_license
ernandofvjr/Jogo-de-Damas
7415156223fa7bf9dc44df555bab15b1875923a3
4543f1a20383c40d8306f43b0e5308b85382c710
refs/heads/master
2020-04-26T21:33:38.630741
2019-03-05T00:46:43
2019-03-05T00:46:43
173,845,023
0
0
null
null
null
null
ISO-8859-1
Java
false
false
657
java
package regras; import Excecoes.DamasException; import componentes.Tabuleiro; public class AndarNaDiagonal extends Regra implements ChecarTres { public AndarNaDiagonal(Tabuleiro tabuleiro){ setTabuleiro(tabuleiro); } /** * checa se a peça está andando na diagonal */ public boolean checar(int linhaOrigem, int colunaOrigem, int linhaDestino, int colunaDestino) throws DamasException{ int direcaoLinha = linhaDestino - linhaOrigem; int direcaoColuna = colunaDestino - colunaOrigem; if(direcaoLinha == 0 || direcaoColuna == 0){ throw new DamasException("Casas subsequentes nao podem ser ocupadas"); } return true; } }
3169a3790326529b6bb004f585196d8c2847018c
8aeaa60c93463b72799b8d0d108d1afd96a02731
/src/main/java/com/ds/springexample/service/ProductManagerService.java
8b87790834d00dbd49d851da3a3b18797b4699d8
[]
no_license
malathiarumugam/spring
77e85da5a989faac7ddefd434c7c703e2cbb456e
8cfe181d98eb1081983fae057252ab53085b2d92
refs/heads/master
2020-04-10T08:43:35.397174
2016-07-22T05:57:09
2016-07-22T05:57:09
50,033,054
1
8
null
null
null
null
UTF-8
Java
false
false
1,210
java
package com.ds.springexample.service; import com.ds.springexample.dao.ProductRepository; import com.ds.springexample.model.Product; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; /** * @author Dogukan Sonmez */ @Service public class ProductManagerService { private static final Logger logger = LoggerFactory.getLogger(ProductManagerService.class); @Autowired private ProductRepository repository; public Product getProductById(Long id) { if (id != null) { return repository.get(id); } else { return new Product(); } } public List getAllProducts() { return repository.getAll(); } public void saveProduct(Product product) { logger.info("-------------Service product: " + product); repository.save(product); } public void updateProduct(Product product) { repository.update(product); } public void deleteProduct(Long id) { } }
bf5e50ac74fccaefdfadba96241f811870028ab8
4b25fdf8aefc6035df743141a4e14bbf33c28f47
/src/main/java/com/containers/SimpleHashMap.java
7756739729379a16eb6866cd87ac50b59934acde
[]
no_license
Linklmm/thinkInJava
5be0f014c6641ad522f93e816984b529ef08576a
644346757575d87cd35beb1f55d5835f7667d9eb
refs/heads/master
2020-03-26T16:18:02.950337
2019-11-29T03:00:17
2019-11-29T03:00:17
145,092,648
1
0
null
null
null
null
UTF-8
Java
false
false
2,099
java
package com.containers; import java.util.*; /** * @author lmm * @Title: SimpleHashMap * @ProjectName thinkInJava * @Description: TODO * @date 19-1-11上午10:13 */ public class SimpleHashMap<K, V> extends AbstractMap<K, V> { static final int SIZE = 997; @SuppressWarnings("unchecked") LinkedList<MapEntry<K, V>>[] buckets = new LinkedList[SIZE]; @Override public V put(K key, V value) { V oldValue = null; //abs函数返回参数的绝对值 int index = Math.abs(key.hashCode()) % SIZE; if (buckets[index] == null) { buckets[index] = new LinkedList<MapEntry<K, V>>(); } LinkedList<MapEntry<K, V>> bucket = buckets[index]; //创建传进来的mapEntry MapEntry<K, V> pair = new MapEntry<K, V>(key, value); boolean found = false; ListIterator<MapEntry<K, V>> it = bucket.listIterator(); while (it.hasNext()) { MapEntry<K, V> ipair = it.next(); //如果传进来的key已存在那么 if (ipair.getKey().equals(key)) { oldValue = ipair.getValue(); //将旧值换成新值 it.set(pair); found = true; break; } } if (!found) { buckets[index].add(pair); } return oldValue; } @Override public V get(Object key){ int index = Math.abs(key.hashCode())%SIZE; if (buckets[index] == null){ return null; } for (MapEntry<K,V> ipair : buckets[index]) { if (ipair.getKey().equals(key)){ return ipair.getValue(); } } return null; } @Override public Set<Entry<K, V>> entrySet() { Set<Map.Entry<K,V>> set = new HashSet<Entry<K, V>>(); for (LinkedList<MapEntry<K,V>> bucket : buckets){ if (bucket == null){ continue;} for (MapEntry<K,V> mpair : bucket){ set.add(mpair); } } return set; } }
3d647bd7b4e0b618324860cfd525295182e7bbcf
ad05c654b4c553e812021efc925e6541178cfd58
/src/test/java/com/oltruong/teamag/model/AbstractEntityIT.java
ab3852796923e42975f336a663c17ca5aaaf8306
[ "MIT" ]
permissive
oltruong/teamag
1d945541b4ad6423b9b3eb80080c73ae72b9701c
1550f891154a0d6359256dbe4b3fadb07bdf7854
refs/heads/master
2021-01-18T22:07:52.783839
2019-07-11T11:50:23
2019-07-11T11:50:28
5,967,421
5
2
null
2016-12-20T11:53:25
2012-09-26T14:55:35
Java
UTF-8
Java
false
false
1,297
java
package com.oltruong.teamag.model; import org.junit.After; import org.junit.Before; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; public abstract class AbstractEntityIT { protected EntityManagerFactory entityManagerFactory; protected EntityManager entityManager; protected EntityTransaction transaction; @Before public void setup() { entityManagerFactory = Persistence.createEntityManagerFactory("testPersistence"); entityManager = entityManagerFactory.createEntityManager(); transaction = entityManager.getTransaction(); transaction.begin(); } @After public void tearDown() { entityManager.close(); entityManagerFactory.close(); } protected Object createWithoutCommit(Object object) { entityManager.persist(object); return object; } protected Object createWithCommit(Object object) { object = createWithoutCommit(object); transaction.commit(); return object; } protected void commit() { transaction.commit(); } protected void persist(Object object) { entityManager.persist(object); } }
72f54383870a653dde7503bbb6b30c36b4d1a36e
7bd2d65d1adc6e7c47523f5dafc20d0fe857fab1
/tarea extra yasmany/concatenar/src/concatenar/InterfaceGrafo.java
3f35df269a0abf73632f1222404699f1d2d12c17
[]
no_license
ymadrazovalladares/java
d5d0d54508f3d50daa885d54f87f16b0735079a6
433446cb8f47feddc76caed8f2e1546fbee3279d
refs/heads/master
2020-04-01T02:51:12.816743
2019-02-18T18:32:43
2019-02-18T18:32:43
152,798,212
0
0
null
null
null
null
UTF-8
Java
false
false
412
java
package concatenar; import java.util.ArrayList; public interface InterfaceGrafo<T> { void addNodo(T valor); void addAdyacentes(T nodo, T esAdyacenteA); void addAdyacentes(T nodo, T esAdyacenteA, Integer ponderacion); Object[] getNodos(); Object[] getListadeNodosdeQuienEsAdyacente(T nodo); void eliminarAdyacentes(T nodo, T dejaDeSerAdyacenteA); void eliminaNodo(T nodo); }
0b31049d64c074bfb7d204cd4395961d1455b6e9
aa2ba134b14b214172de43f7d84c9f75a8d75151
/src/test/java/com/milfist/springbootservice/service/DataByIdTest.java
24af87dd3ddd87803735b39d0ee23728546e1e59
[]
no_license
Milfist/springboot-war-jar-keycloak-https
a057bdb25b56458bbaa5e4bacf596ea0dd02212c
339a04ee100d28980794fc5ef525fa3ba214bf08
refs/heads/master
2022-12-26T07:10:39.027106
2020-10-02T07:49:42
2020-10-02T07:49:42
298,254,817
0
0
null
null
null
null
UTF-8
Java
false
false
1,311
java
package com.milfist.springbootservice.service; import com.google.gson.Gson; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import java.io.FileNotFoundException; import java.util.List; import static org.junit.jupiter.api.Assertions.*; @ActiveProfiles("local") @SpringBootTest class DataByIdTest { @Autowired DataById dataById; @Test void givenCorrectID_call_getOptionsById_thenReturn_OK() throws Exception { String json = dataById.getDataById("data"); Data data = new Gson().fromJson(json, Data.class); assertAll("data", ()-> assertEquals("Servicio", data.getTitle()), ()-> assertEquals(0, data.getOptions().size()) ); } @Test void givenWrongID_call_getOptionsById_thenReturn_FileNorFoundException() { assertThrows(FileNotFoundException.class, () -> dataById.getDataById("data2")); } @Test void givenCorrectID_withEmptyFile_thenReturnEmptyString() throws Exception { String json = dataById.getDataById("data_null"); assertEquals("", json); } } @lombok.Data class Data { private String title; private List<String> options; private Object security; }
88dc73319ba6aec0e9914eaa57ca9396ac2757bf
edd5bb4e61347e8348a74fef9cb54da92384b07c
/simple/src/main/java/simple/common/controller/CommonController.java
b1cd424c2c99d4de8621c52cde221048d71dbf97
[]
no_license
broomy8/simple
2a4f8cb4565accc2347f94fdd564c218e40a6c34
05ae0b7df2fb9383f3883b09315919b81a60de35
refs/heads/master
2021-01-10T12:55:13.165308
2016-04-08T05:06:40
2016-04-08T05:06:40
55,198,384
0
0
null
null
null
null
UTF-8
Java
false
false
1,556
java
package simple.common.controller; import java.io.File; import java.net.URLEncoder; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import simple.common.common.CommandMap; import simple.common.service.CommonService; @Controller public class CommonController { Logger log = Logger.getLogger(this.getClass()); @Resource(name = "commonService") private CommonService commonService; @RequestMapping(value = "/common/downloadFile.do") public void downloadFile(CommandMap commandMap, HttpServletResponse response) throws Exception { Map<String, Object> map = commonService.selectFileInfo(commandMap.getMap()); String storedFileName = (String) map.get("STORED_FILE_NAME"); String originalFileName = (String) map.get("ORIGINAL_FILE_NAME"); byte fileByte[] = FileUtils.readFileToByteArray(new File("d:\\workspace\\file\\" + storedFileName)); response.setContentType("application/octet-stream"); response.setContentLength(fileByte.length); response.setHeader("Content-Disposition", "attachment; fileName=\"" + URLEncoder.encode(originalFileName, "UTF-8") + "\";"); response.setHeader("Content-Transfer-Encoding", "binary"); response.getOutputStream().write(fileByte); response.getOutputStream().flush(); response.getOutputStream().close(); } }
164dfd672fd34751a98176c70be8b70054934a21
df88ba161d4572cbaf49df5db01736c97aa73123
/cloud-comsuer-order81/src/main/java/com/ys/demo/controller/OrderController.java
45a1659d06b7d8475b77b9a45b318acc437d100e
[]
no_license
dzy32/com.ys.clouddemo
89faaed2e5081cd68d98d82a2aeb2a48f349e2cd
5bc1b0f6bb12b15386c6728240bf5ad5d71cb588
refs/heads/master
2023-03-24T11:55:10.447340
2021-03-23T10:37:10
2021-03-23T10:37:10
327,865,648
0
0
null
null
null
null
UTF-8
Java
false
false
1,168
java
package com.ys.demo.controller; import com.ys.demo.VO.ResultVO; import com.ys.demo.entity.Payment; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.client.RestTemplate; /** * @author ys * @date 2021/1/11 9:36 */ @RestController @RequestMapping("/order") @Slf4j public class OrderController { @Autowired private RestTemplate restTemplate; private static final String PAYMNET_URL= "http://payment-service"; @GetMapping("/get/{id}") public ResultVO<Payment> getPay(@PathVariable("id") String id){ return restTemplate.getForObject(PAYMNET_URL.concat("/payment/payment/get/").concat(id),ResultVO.class); } @PostMapping("/add") public ResultVO<Payment> addPay(@RequestBody Payment payment){ return restTemplate.postForObject(PAYMNET_URL.concat("/payment/payment/add"),payment,ResultVO.class); } @GetMapping("/get/zk") public ResultVO<Payment> getPay(){ return restTemplate.getForObject(PAYMNET_URL.concat("/payment/payment/get/zk"),ResultVO.class); } }
c2eb7f8394e9b806919605e00a14b591ff909d03
ebbd4e78b717ec83ca7ee55765ac8eb725ae869a
/app/src/main/java/com/gy/recyclerviewadapter/adapter/HomeAdapter.java
0a26f5c3237ef2d82c9791b2042214a9fa8e19a6
[]
no_license
newPersonKing/baseAdapter
9132593b80bb296435a156ac9fbbb502a7e75357
c1bdf08199e637786262c1a10ec54bbd49571d5b
refs/heads/master
2020-03-25T01:40:19.015129
2018-08-02T06:11:48
2018-08-02T06:11:48
143,250,223
0
0
null
null
null
null
UTF-8
Java
false
false
717
java
package com.gy.recyclerviewadapter.adapter; import com.chad.library.adapter.base.BaseQuickAdapter; import com.chad.library.adapter.base.BaseViewHolder; import com.gy.recyclerviewadapter.R; import com.gy.recyclerviewadapter.entity.HomeItem; import java.util.List; /** * https://github.com/CymChad/BaseRecyclerViewAdapterHelper */ public class HomeAdapter extends BaseQuickAdapter<HomeItem, BaseViewHolder> { public HomeAdapter(int layoutResId, List data) { super(layoutResId, data); } @Override protected void convert(BaseViewHolder helper, HomeItem item) { helper.setText(R.id.text, item.getTitle()); helper.setImageResource(R.id.icon, item.getImageResource()); } }
7321d2c28b4b9802d8fe5d483bda7d04cdfafd56
28552d7aeffe70c38960738da05ebea4a0ddff0c
/google-ads/src/main/java/com/google/ads/googleads/v4/errors/CollectionSizeErrorEnumOrBuilder.java
979b1d3b0674061270b9c909ada15a8f60a77051
[ "Apache-2.0" ]
permissive
PierrickVoulet/google-ads-java
6f84a3c542133b892832be8e3520fb26bfdde364
f0a9017f184cad6a979c3048397a944849228277
refs/heads/master
2021-08-22T08:13:52.146440
2020-12-09T17:10:48
2020-12-09T17:10:48
250,642,529
0
0
Apache-2.0
2020-03-27T20:41:26
2020-03-27T20:41:25
null
UTF-8
Java
false
true
385
java
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/ads/googleads/v4/errors/collection_size_error.proto package com.google.ads.googleads.v4.errors; public interface CollectionSizeErrorEnumOrBuilder extends // @@protoc_insertion_point(interface_extends:google.ads.googleads.v4.errors.CollectionSizeErrorEnum) com.google.protobuf.MessageOrBuilder { }
b20b42b6477df0dcdc6165d8cdc5924c1463cf31
c3c26f2aa42dba0e78e09f8fdd330be21515566f
/app/src/main/java/com/example/mycalendar/Event.java
167a0a645aead8165c2a4b53e9a067a2104a8e09
[]
no_license
tmnguyen1403/AndroidCalendar
4f415b0bcf1ad803aff6258cc65d70551e138e36
1de5ba448a6b6ca96c6141c688f64cede991ce9a
refs/heads/main
2023-01-08T17:17:29.915645
2020-11-11T05:26:24
2020-11-11T05:26:24
311,789,337
1
0
null
null
null
null
UTF-8
Java
false
false
803
java
package com.example.mycalendar; import androidx.annotation.NonNull; import org.json.JSONException; import org.json.JSONObject; public class Event { public String id; public String name; public String description; public String location; public String startDate; public String endDate; public String startTime; public String endTime; public void setData(JSONObject data) throws JSONException { id = data.getString("id"); name = data.getString("name"); description = data.getString("description"); location = data.getString("location"); startDate = data.getString("startDate"); endDate = data.getString("endDate"); startTime = data.getString("startTime"); endTime = data.getString("endTime"); } }
95425138bcb114befb5fb0358eb1fa94d5edf8e9
dcb97569f10a7457b9c4bb27bf7b79b59e8a9198
/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java
e609777ab41b0f3d0fa0116da973ff62788fa4dc
[ "Apache-2.0" ]
permissive
eric0755/bazel1
02a0fda2a9ec89f78d82d7de627930ead2d348f5
1d1563372d940965d9304e26772a3688eb31226d
refs/heads/master
2020-06-04T07:25:16.754843
2019-06-14T12:09:08
2019-06-14T12:09:08
191,923,464
0
0
null
null
null
null
UTF-8
Java
false
false
196,816
java
// Copyright 2017 The Bazel Authors. 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.google.devtools.build.lib.rules.android; import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.getFirstArtifactEndingWith; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.prettyArtifactNames; import static com.google.devtools.build.lib.rules.java.JavaCompileActionTestHelper.getJavacArguments; import static com.google.devtools.build.lib.rules.java.JavaCompileActionTestHelper.getProcessorpath; import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; import com.google.common.base.Ascii; import com.google.common.base.Joiner; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Streams; import com.google.common.truth.Truth; import com.google.devtools.build.lib.actions.Action; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.util.ActionsTestUtil; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.FilesToRunProvider; import com.google.devtools.build.lib.analysis.OutputGroupInfo; import com.google.devtools.build.lib.analysis.actions.FileWriteAction; import com.google.devtools.build.lib.analysis.actions.SpawnAction; import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.packages.FileTarget; import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.packages.util.BazelMockAndroidSupport; import com.google.devtools.build.lib.rules.android.AndroidRuleClasses.MultidexMode; import com.google.devtools.build.lib.rules.android.deployinfo.AndroidDeployInfoOuterClass.AndroidDeployInfo; import com.google.devtools.build.lib.rules.cpp.CppFileTypes; import com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider; import com.google.devtools.build.lib.rules.java.JavaCompileAction; import com.google.devtools.build.lib.rules.java.JavaInfo; import com.google.devtools.build.lib.rules.java.JavaSemantics; import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData; import com.google.devtools.build.lib.testutil.MoreAsserts; import com.google.devtools.build.lib.util.FileType; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Set; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; /** * A test for {@link com.google.devtools.build.lib.rules.android.AndroidBinary}. */ @RunWith(JUnit4.class) public class AndroidBinaryTest extends AndroidBuildViewTestCase { @Before public void setupCcToolchain() throws Exception { getAnalysisMock().ccSupport().setupCcToolchainConfigForCpu(mockToolsConfig, "armeabi-v7a"); } @Before public void createFiles() throws Exception { scratch.file("java/android/BUILD", "android_binary(name = 'app',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res/**']),", " )"); scratch.file("java/android/res/values/strings.xml", "<resources><string name = 'hello'>Hello Android!</string></resources>"); scratch.file("java/android/A.java", "package android; public class A {};"); } @Test public void testAndroidSplitTransitionWithInvalidCpu() throws Exception { scratch.file( "test/skylark/my_rule.bzl", "def impl(ctx): ", " return []", "my_rule = rule(", " implementation = impl,", " attrs = {", " 'deps': attr.label_list(cfg = android_common.multi_cpu_configuration),", " 'dep': attr.label(cfg = android_common.multi_cpu_configuration),", " })"); scratch.file( "test/skylark/BUILD", "load('//test/skylark:my_rule.bzl', 'my_rule')", "my_rule(name = 'test', deps = [':main'], dep = ':main')", "cc_binary(name = 'main', srcs = ['main.c'])"); BazelMockAndroidSupport.setupNdk(mockToolsConfig); // --android_cpu with --android_crosstool_top also triggers the split transition. useConfiguration("--fat_apk_cpu=doesnotexist", "--android_crosstool_top=//android/crosstool:everything"); AssertionError noToolchainError = assertThrows(AssertionError.class, () -> getConfiguredTarget("//test/skylark:test")); assertThat(noToolchainError) .hasMessageThat() .contains("does not contain a toolchain for cpu 'doesnotexist'"); } @Test public void testAssetsInExternalRepository() throws Exception { FileSystemUtils.appendIsoLatin1( scratch.resolve("WORKSPACE"), "local_repository(name='r', path='/r')"); scratch.file("/r/WORKSPACE"); scratch.file("/r/p/BUILD", "filegroup(name='assets', srcs=['a/b'])"); scratch.file("/r/p/a/b"); invalidatePackages(); scratchConfiguredTarget("java/a", "a", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " assets = ['@r//p:assets'],", " assets_dir = '')"); } @Test public void testMultidexModeAndMainDexProguardSpecs() throws Exception { checkError("java/a", "a", "only allowed if 'multidex' is set to 'legacy'", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " main_dex_proguard_specs = ['foo'])"); } @Test public void testAndroidManifestWithCustomName() throws Exception { scratchConfiguredTarget( "java/a", "a", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'SomeOtherAndroidManifest.xml')"); assertNoEvents(); } @Test public void testMainDexProguardSpecs() throws Exception { useConfiguration("--noincremental_dexing"); ConfiguredTarget ct = scratchConfiguredTarget("java/a", "a", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " multidex = 'legacy',", " main_dex_proguard_specs = ['a.spec'])"); Artifact intermediateJar = artifactByPath(ImmutableList.of(getCompressedUnsignedApk(ct)), ".apk", ".dex.zip", ".dex.zip", "main_dex_list.txt", "_intermediate.jar"); List<String> args = getGeneratingSpawnActionArgs(intermediateJar); MoreAsserts.assertContainsSublist(args, "-include", "java/a/a.spec"); assertThat(Joiner.on(" ").join(args)).doesNotContain("mainDexClasses.rules"); } @Test public void testMainDexListObfuscation() throws Exception { useConfiguration("--noincremental_dexing"); scratch.file("/java/a/list.txt"); ConfiguredTarget ct = scratchConfiguredTarget( "java/a", "a", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " multidex = 'manual_main_dex',", " proguard_generate_mapping = 1,", " main_dex_list = 'list.txt')"); Artifact obfuscatedDexList = artifactByPath( ImmutableList.of(getCompressedUnsignedApk(ct)), ".apk", ".dex.zip", ".dex.zip", "main_dex_list_obfuscated.txt"); List<String> args = getGeneratingSpawnActionArgs(obfuscatedDexList); assertThat(args.get(0)).contains("dex_list_obfuscator"); MoreAsserts.assertContainsSublist(args, "--input", "java/a/list.txt"); } @Test public void testNonLegacyNativeDepsDoesNotPolluteDexSharding() throws Exception { scratch.file("java/a/BUILD", "android_binary(name = 'a',", " manifest = 'AndroidManifest.xml',", " multidex = 'native',", " deps = [':cc'],", " dex_shards = 2)", "cc_library(name = 'cc',", " srcs = ['cc.cc'])"); Artifact jarShard = artifactByPath( ImmutableList.of(getCompressedUnsignedApk(getConfiguredTarget("//java/a:a"))), ".apk", "classes.dex.zip", "shard1.dex.zip", "shard1.jar.dex.zip"); Iterable<Artifact> shardInputs = getGeneratingAction(jarShard).getInputs(); assertThat(getFirstArtifactEndingWith(shardInputs, ".txt")).isNull(); } @Test public void testJavaPluginProcessorPath() throws Exception { scratch.file("java/test/BUILD", "java_library(name = 'plugin_dep',", " srcs = [ 'ProcessorDep.java'])", "java_plugin(name = 'plugin',", " srcs = ['AnnotationProcessor.java'],", " processor_class = 'com.google.process.stuff',", " deps = [ ':plugin_dep' ])", "android_binary(name = 'to_be_processed',", " manifest = 'AndroidManifest.xml',", " plugins = [':plugin'],", " srcs = ['ToBeProcessed.java'])"); ConfiguredTarget target = getConfiguredTarget("//java/test:to_be_processed"); JavaCompileAction javacAction = (JavaCompileAction) getGeneratingAction(getBinArtifact("libto_be_processed.jar", target)); assertThat(getProcessorNames(javacAction)).contains("com.google.process.stuff"); assertThat(getProcessorNames(javacAction)).hasSize(1); assertThat( ActionsTestUtil.baseArtifactNames( getInputs(javacAction, getProcessorpath(javacAction)))) .containsExactly("libplugin.jar", "libplugin_dep.jar"); assertThat( actionsTestUtil() .predecessorClosureOf(getFilesToBuild(target), JavaSemantics.JAVA_SOURCE)) .isEqualTo("ToBeProcessed.java AnnotationProcessor.java ProcessorDep.java"); } // Same test as above, enabling the plugin through the command line. @Test public void testPluginCommandLine() throws Exception { scratch.file("java/test/BUILD", "java_library(name = 'plugin_dep',", " srcs = [ 'ProcessorDep.java'])", "java_plugin(name = 'plugin',", " srcs = ['AnnotationProcessor.java'],", " processor_class = 'com.google.process.stuff',", " deps = [ ':plugin_dep' ])", "android_binary(name = 'to_be_processed',", " manifest = 'AndroidManifest.xml',", " srcs = ['ToBeProcessed.java'])"); useConfiguration("--plugin=//java/test:plugin"); ConfiguredTarget target = getConfiguredTarget("//java/test:to_be_processed"); JavaCompileAction javacAction = (JavaCompileAction) getGeneratingAction(getBinArtifact("libto_be_processed.jar", target)); assertThat(getProcessorNames(javacAction)).contains("com.google.process.stuff"); assertThat(getProcessorNames(javacAction)).hasSize(1); assertThat( ActionsTestUtil.baseArtifactNames( getInputs(javacAction, getProcessorpath(javacAction)))) .containsExactly("libplugin.jar", "libplugin_dep.jar"); assertThat( actionsTestUtil() .predecessorClosureOf(getFilesToBuild(target), JavaSemantics.JAVA_SOURCE)) .isEqualTo("ToBeProcessed.java AnnotationProcessor.java ProcessorDep.java"); } @Test public void testInvalidPlugin() throws Exception { checkError("java/test", "lib", // error: getErrorMsgMisplacedRules("plugins", "android_binary", "//java/test:lib", "java_library", "//java/test:not_a_plugin"), // BUILD file: "java_library(name = 'not_a_plugin',", " srcs = [ 'NotAPlugin.java'])", "android_binary(name = 'lib',", " plugins = [':not_a_plugin'],", " manifest = 'AndroidManifest.xml',", " srcs = ['Lib.java'])"); } @Test public void testBaselineCoverageArtifacts() throws Exception { useConfiguration("--collect_code_coverage"); ConfiguredTarget target = scratchConfiguredTarget("java/com/google/a", "bin", "android_binary(name='bin', srcs=['Main.java'], manifest='AndroidManifest.xml')"); assertThat(baselineCoverageArtifactBasenames(target)).containsExactly("Main.java"); } @Test public void testSameSoFromMultipleDeps() throws Exception { scratch.file("java/d/BUILD", "genrule(name='genrule', srcs=[], outs=['genrule.so'], cmd='')", "cc_library(name='cc1', srcs=[':genrule.so'])", "cc_library(name='cc2', srcs=[':genrule.so'])", "android_binary(name='ab', deps=[':cc1', ':cc2'], manifest='AndroidManifest.xml')"); getConfiguredTarget("//java/d:ab"); } @Test public void testSimpleBinary_desugarJava8() throws Exception { useConfiguration("--experimental_desugar_for_android"); ConfiguredTarget binary = getConfiguredTarget("//java/android:app"); SpawnAction action = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( actionsTestUtil().artifactClosureOf(getFilesToBuild(binary)), "_deploy.jar"); assertThat(ActionsTestUtil.baseArtifactNames(action.getInputs())) .contains("libapp.jar_desugared.jar"); assertThat(ActionsTestUtil.baseArtifactNames(action.getInputs())) .doesNotContain("libapp.jar"); } /** * Tests that --experimental_check_desugar_deps causes the relevant flags to be set on desugaring * and singlejar actions, and makes sure the deploy jar is built even when just building an APK. */ @Test public void testSimpleBinary_checkDesugarDepsAlwaysHappens() throws Exception { useConfiguration("--experimental_check_desugar_deps"); ConfiguredTarget binary = getConfiguredTarget("//java/android:app"); assertNoEvents(); // 1. Find app's deploy jar and make sure checking flags are set for it and its inputs SpawnAction singlejar = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( getFilesToBuild(binary), "/app_deploy.jar"); assertThat(getGeneratingSpawnActionArgs(singlejar.getPrimaryOutput())) .contains("--check_desugar_deps"); SpawnAction desugar = (SpawnAction) actionsTestUtil() .getActionForArtifactEndingWith(singlejar.getInputs(), "/libapp.jar_desugared.jar"); assertThat(desugar).isNotNull(); assertThat(getGeneratingSpawnActionArgs(desugar.getPrimaryOutput())) .contains("--emit_dependency_metadata_as_needed"); // 2. Make sure all APK outputs depend on the deploy Jar. int found = 0; for (Artifact built : getFilesToBuild(binary)) { if (built.getExtension().equals("apk")) { // If this assertion breaks then APK artifacts have stopped depending on deploy jars. // If that's desired then we'll need to make sure dependency checking is done in another // action that APK artifacts depend on, in addition to the check that happens when building // deploy.jars, which we assert above. assertWithMessage("%s dependency on deploy.jar", built.getFilename()) .that(actionsTestUtil().artifactClosureOf(built)) .contains(singlejar.getPrimaryOutput()); ++found; } } assertThat(found).isEqualTo(2 /* signed and unsigned apks */); } // regression test for #3169099 @Test public void testBinarySrcs() throws Exception { scratch.file("java/srcs/a.foo", "foo"); scratch.file("java/srcs/BUILD", "android_binary(name = 'valid', manifest = 'AndroidManifest.xml', " + "srcs = ['a.java', 'b.srcjar', ':gvalid', ':gmix'])", "android_binary(name = 'invalid', manifest = 'AndroidManifest.xml', " + "srcs = ['a.foo', ':ginvalid'])", "android_binary(name = 'mix', manifest = 'AndroidManifest.xml', " + "srcs = ['a.java', 'a.foo'])", "genrule(name = 'gvalid', srcs = ['a.java'], outs = ['b.java'], cmd = '')", "genrule(name = 'ginvalid', srcs = ['a.java'], outs = ['b.foo'], cmd = '')", "genrule(name = 'gmix', srcs = ['a.java'], outs = ['c.java', 'c.foo'], cmd = '')" ); assertSrcsValidityForRuleType("//java/srcs", "android_binary", ".java or .srcjar"); } // regression test for #3169095 @Test public void testXmbInSrcs_NotPermittedButDoesNotThrow() throws Exception { reporter.removeHandler(failFastHandler); scratchConfiguredTarget("java/xmb", "a", "android_binary(name = 'a', manifest = 'AndroidManifest.xml', srcs = ['a.xmb'])"); // We expect there to be an error here because a.xmb is not a valid src, // and more importantly, no exception to have been thrown. assertContainsEvent("in srcs attribute of android_binary rule //java/xmb:a: " + "target '//java/xmb:a.xmb' does not exist"); } @Test public void testNativeLibraryBasenameCollision() throws Exception { reporter.removeHandler(failFastHandler); // expect errors scratch.file("java/android/common/BUILD", "cc_library(name = 'libcommon_armeabi',", " srcs = ['armeabi/native.so'],)"); scratch.file("java/android/app/BUILD", "cc_library(name = 'libnative',", " srcs = ['native.so'],)", "android_binary(name = 'b',", " srcs = ['A.java'],", " deps = [':libnative', '//java/android/common:libcommon_armeabi'],", " manifest = 'AndroidManifest.xml',", " )"); getConfiguredTarget("//java/android/app:b"); assertContainsEvent("Each library in the transitive closure must have a unique basename to " + "avoid name collisions when packaged into an apk, but two libraries have the basename " + "'native.so': java/android/common/armeabi/native.so and java/android/app/native.so"); } private void setupNativeLibrariesForLinking() throws Exception { scratch.file("java/android/common/BUILD", "cc_library(name = 'common_native',", " srcs = ['common.cc'],)", "android_library(name = 'common',", " exports = [':common_native'],)"); scratch.file("java/android/app/BUILD", "cc_library(name = 'native',", " srcs = ['native.cc'],)", "android_binary(name = 'auto',", " srcs = ['A.java'],", " deps = [':native', '//java/android/common:common'],", " manifest = 'AndroidManifest.xml',", " )", "android_binary(name = 'off',", " srcs = ['A.java'],", " deps = [':native', '//java/android/common:common'],", " manifest = 'AndroidManifest.xml',", " )"); } private void assertNativeLibraryLinked(ConfiguredTarget target, String... srcNames) { Artifact linkedLib = getOnlyElement(getNativeLibrariesInApk(target)); assertThat(linkedLib.getFilename()) .isEqualTo("lib" + target.getLabel().toPathFragment().getBaseName() + ".so"); assertThat(linkedLib.isSourceArtifact()).isFalse(); assertWithMessage("Native libraries were not linked to produce " + linkedLib) .that(getGeneratingLabelForArtifact(linkedLib)) .isEqualTo(target.getLabel()); assertThat(artifactsToStrings(actionsTestUtil().artifactClosureOf(linkedLib))) .containsAtLeastElementsIn(ImmutableSet.copyOf(Arrays.asList(srcNames))); } @Test public void testNativeLibrary_LinksLibrariesWhenCodeIsPresent() throws Exception { setupNativeLibrariesForLinking(); assertNativeLibraryLinked(getConfiguredTarget("//java/android/app:auto"), "src java/android/common/common.cc", "src java/android/app/native.cc"); assertNativeLibraryLinked(getConfiguredTarget("//java/android/app:off"), "src java/android/common/common.cc", "src java/android/app/native.cc"); } @Test public void testNativeLibrary_CopiesLibrariesDespiteExtraLayersOfIndirection() throws Exception { scratch.file("java/android/app/BUILD", "cc_library(name = 'native_dep',", " srcs = ['dep.so'])", "cc_library(name = 'native',", " srcs = ['native_prebuilt.so'],", " deps = [':native_dep'])", "cc_library(name = 'native_wrapper',", " deps = [':native'])", "android_binary(name = 'app',", " srcs = ['A.java'],", " deps = [':native_wrapper'],", " manifest = 'AndroidManifest.xml',", " )"); assertNativeLibrariesCopiedNotLinked(getConfiguredTarget("//java/android/app:app"), "src java/android/app/dep.so", "src java/android/app/native_prebuilt.so"); } @Test public void testNativeLibrary_CopiesLibrariesWrappedInCcLibraryWithSameName() throws Exception { scratch.file("java/android/app/BUILD", "cc_library(name = 'native',", " srcs = ['libnative.so'])", "android_binary(name = 'app',", " srcs = ['A.java'],", " deps = [':native'],", " manifest = 'AndroidManifest.xml',", " )"); assertNativeLibrariesCopiedNotLinked(getConfiguredTarget("//java/android/app:app"), "src java/android/app/libnative.so"); } @Test public void testNativeLibrary_LinksWhenPrebuiltArchiveIsSupplied() throws Exception { scratch.file("java/android/app/BUILD", "cc_library(name = 'native_dep',", " srcs = ['dep.lo'])", "cc_library(name = 'native',", " srcs = ['native_prebuilt.a'],", " deps = [':native_dep'])", "cc_library(name = 'native_wrapper',", " deps = [':native'])", "android_binary(name = 'app',", " srcs = ['A.java'],", " deps = [':native_wrapper'],", " manifest = 'AndroidManifest.xml',", " )"); assertNativeLibraryLinked(getConfiguredTarget("//java/android/app:app"), "src java/android/app/native_prebuilt.a"); } @Test public void testNativeLibrary_CopiesFullLibrariesInIfsoMode() throws Exception { useConfiguration("--interface_shared_objects"); scratch.file("java/android/app/BUILD", "cc_library(name = 'native_dep',", " srcs = ['dep.so'])", "cc_library(name = 'native',", " srcs = ['native.cc', 'native_prebuilt.so'],", " deps = [':native_dep'])", "android_binary(name = 'app',", " srcs = ['A.java'],", " deps = [':native'],", " manifest = 'AndroidManifest.xml',", " )"); ConfiguredTarget app = getConfiguredTarget("//java/android/app:app"); Iterable<Artifact> nativeLibraries = getNativeLibrariesInApk(app); assertThat(artifactsToStrings(nativeLibraries)) .containsAtLeast("src java/android/app/native_prebuilt.so", "src java/android/app/dep.so"); assertThat(FileType.filter(nativeLibraries, CppFileTypes.INTERFACE_SHARED_LIBRARY)) .isEmpty(); } @Test public void testNativeLibrary_ProvidesLinkerScriptToLinkAction() throws Exception { scratch.file("java/android/app/BUILD", "cc_library(name = 'native',", " srcs = ['native.cc'],", " linkopts = ['-Wl,-version-script', '$(location jni.lds)'],", " deps = ['jni.lds'],)", "android_binary(name = 'app',", " srcs = ['A.java'],", " deps = [':native'],", " manifest = 'AndroidManifest.xml',", " )"); ConfiguredTarget app = getConfiguredTarget("//java/android/app:app"); Artifact copiedLib = getOnlyElement(getNativeLibrariesInApk(app)); Artifact linkedLib = getOnlyElement(getGeneratingAction(copiedLib).getInputs()); Iterable<Artifact> linkInputs = getGeneratingAction(linkedLib).getInputs(); assertThat(ActionsTestUtil.baseArtifactNames(linkInputs)).contains("jni.lds"); } /** Regression test for http://b/33173461. */ @Test public void testIncrementalDexingUsesDexArchives_binaryDependingOnAliasTarget() throws Exception { scratch.file( "java/com/google/android/BUILD", "android_library(", " name = 'dep',", " srcs = ['dep.java'],", " resource_files = glob(['res/**']),", " manifest = 'AndroidManifest.xml',", ")", "alias(", " name = 'alt',", " actual = ':dep',", ")", "android_binary(", " name = 'top',", " srcs = ['foo.java', 'bar.srcjar'],", " multidex = 'native',", " manifest = 'AndroidManifest.xml',", " deps = [':alt',],", ")"); ConfiguredTarget topTarget = getConfiguredTarget("//java/com/google/android:top"); assertNoEvents(); Action shardAction = getGeneratingAction(getBinArtifact("_dx/top/classes.jar", topTarget)); for (Artifact input : getNonToolInputs(shardAction)) { String basename = input.getFilename(); // all jars are converted to dex archives assertWithMessage(basename) .that(!basename.contains(".jar") || basename.endsWith(".jar.dex.zip")) .isTrue(); // all jars are desugared before being converted if (basename.endsWith(".jar.dex.zip")) { assertThat(getGeneratingAction(input).getPrimaryInput().getFilename()) .isEqualTo(basename.substring(0, basename.length() - ".jar.dex.zip".length()) + ".jar_desugared.jar"); } } // Make sure exactly the dex archives generated for top and dependents appear. We also *don't* // want neverlink and unused_dep to appear, and to be safe we do so by explicitly enumerating // *all* expected input dex archives. assertThat( Iterables.filter( ActionsTestUtil.baseArtifactNames(getNonToolInputs(shardAction)), Predicates.containsPattern("\\.jar"))) .containsExactly( // top's dex archives "libtop.jar.dex.zip", "top_resources.jar.dex.zip", // dep's dex archives "libdep.jar.dex.zip"); } @Test public void testIncrementalDexingDisabledWithBlacklistedDexopts() throws Exception { // Even if we mark a dx flag as supported, incremental dexing isn't used with blacklisted // dexopts (unless incremental_dexing attribute is set, which a different test covers) useConfiguration("--incremental_dexing", "--non_incremental_per_target_dexopts=--no-locals", "--dexopts_supported_in_incremental_dexing=--no-locals"); scratch.file( "java/com/google/android/BUILD", "android_binary(", " name = 'top',", " srcs = ['foo.java', 'bar.srcjar'],", " manifest = 'AndroidManifest.xml',", " dexopts = ['--no-locals'],", " dex_shards = 2,", " multidex = 'native',", ")"); ConfiguredTarget topTarget = getConfiguredTarget("//java/com/google/android:top"); assertNoEvents(); Action shardAction = getGeneratingAction(getBinArtifact("_dx/top/shard1.jar", topTarget)); assertThat( Iterables.filter( ActionsTestUtil.baseArtifactNames(getNonToolInputs(shardAction)), Predicates.containsPattern("\\.jar\\.dex\\.zip"))) .isEmpty(); // no dex archives are used } @Test public void testIncrementalDexingDisabledWithProguard() throws Exception { scratch.file( "java/com/google/android/BUILD", "android_binary(", " name = 'top',", " srcs = ['foo.java', 'bar.srcjar'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard.cfg'],", ")"); ConfiguredTarget topTarget = getConfiguredTarget("//java/com/google/android:top"); assertNoEvents(); Action dexAction = getGeneratingAction(getBinArtifact("_dx/top/classes.dex", topTarget)); assertThat( Iterables.filter( ActionsTestUtil.baseArtifactNames(dexAction.getInputs()), Predicates.containsPattern("\\.jar"))) .containsExactly("top_proguard.jar", "dx_binary.jar"); // proguard output is used directly } @Test public void testIncrementalDexing_incompatibleWithProguardWhenDisabled() throws Exception { useConfiguration("--experimental_incremental_dexing_after_proguard=0"); // disable with Proguard checkError("java/com/google/android", "top", "target cannot be incrementally dexed", "android_binary(", " name = 'top',", " srcs = ['foo.java', 'bar.srcjar'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard.cfg'],", " incremental_dexing = 1,", ")"); } @Test public void testIncrementalDexingAfterProguard_unsharded() throws Exception { useConfiguration("--experimental_incremental_dexing_after_proguard=1"); // Use "legacy" multidex mode so we get a main dex list file and can test that it's passed to // the splitter action (similar to _withDexShards below), unlike without the dex splitter where // the main dex list goes to the merging action. scratch.file( "java/com/google/android/BUILD", "android_binary(", " name = 'top',", " srcs = ['foo.java', 'bar.srcjar'],", " manifest = 'AndroidManifest.xml',", " incremental_dexing = 1,", " multidex = 'legacy',", " dexopts = ['--minimal-main-dex', '--positions=none'],", " proguard_specs = ['b.pro'],", ")"); ConfiguredTarget topTarget = getConfiguredTarget("//java/com/google/android:top"); assertNoEvents(); SpawnAction shardAction = getGeneratingSpawnAction(getBinArtifact("_dx/top/classes.dex.zip", topTarget)); assertThat(shardAction.getArguments()).contains("--main-dex-list"); assertThat(shardAction.getArguments()).contains("--minimal-main-dex"); assertThat(ActionsTestUtil.baseArtifactNames(getNonToolInputs(shardAction))) .containsExactly("classes.jar", "main_dex_list.txt"); // --positions dexopt is supported after Proguard, even though not normally otherwise assertThat( paramFileArgsForAction( getGeneratingSpawnAction(getBinArtifact("_dx/top/classes.jar", topTarget)))) .contains("--positions=none"); } @Test public void testIncrementalDexingAfterProguard_autoShardedMultidexAutoOptIn() throws Exception { useConfiguration("--experimental_incremental_dexing_after_proguard=3", "--experimental_incremental_dexing_after_proguard_by_default"); // Use "legacy" multidex mode so we get a main dex list file and can test that it's passed to // the splitter action (similar to _withDexShards below), unlike without the dex splitter where // the main dex list goes to the merging action. scratch.file( "java/com/google/android/BUILD", "android_binary(", " name = 'top',", " srcs = ['foo.java', 'bar.srcjar'],", " manifest = 'AndroidManifest.xml',", " multidex = 'legacy',", " dexopts = ['--minimal-main-dex', '--positions=none'],", " proguard_specs = ['b.pro'],", ")"); // incremental_dexing = 1 attribute not needed ConfiguredTarget topTarget = getConfiguredTarget("//java/com/google/android:top"); assertNoEvents(); SpawnAction splitAction = getGeneratingSpawnAction(getTreeArtifact("dexsplits/top", topTarget)); assertThat(splitAction.getArguments()).contains("--main-dex-list"); assertThat(splitAction.getArguments()).contains("--minimal-main-dex"); assertThat(ActionsTestUtil.baseArtifactNames(getNonToolInputs(splitAction))) .containsExactly("shard1.jar.dex.zip", "shard2.jar.dex.zip", "shard3.jar.dex.zip", "main_dex_list.txt"); SpawnAction shuffleAction = getGeneratingSpawnAction(getBinArtifact("_dx/top/shard1.jar", topTarget)); assertThat(shuffleAction.getArguments()).doesNotContain("--main-dex-list"); assertThat(ActionsTestUtil.baseArtifactNames(getNonToolInputs(shuffleAction))) .containsExactly("top_proguard.jar"); // --positions dexopt is supported after Proguard, even though not normally otherwise assertThat( paramFileArgsForAction( getGeneratingSpawnAction(getBinArtifact("_dx/top/shard3.jar.dex.zip", topTarget)))) .contains("--positions=none"); } @Test public void testIncrementalDexingAfterProguard_explicitDexShards() throws Exception { useConfiguration("--experimental_incremental_dexing_after_proguard=2"); // Use "legacy" multidex mode so we get a main dex list file and can test that it's passed to // the shardAction, not to the subsequent dexMerger action. Without dex_shards, main dex list // file goes to the dexMerger instead (see _multidex test). scratch.file( "java/com/google/android/BUILD", "android_binary(", " name = 'top',", " srcs = ['foo.java', 'bar.srcjar'],", " manifest = 'AndroidManifest.xml',", " dex_shards = 25,", " incremental_dexing = 1,", " multidex = 'legacy',", " proguard_specs = ['b.pro'],", ")"); ConfiguredTarget topTarget = getConfiguredTarget("//java/com/google/android:top"); assertNoEvents(); SpawnAction shardAction = getGeneratingSpawnAction(getBinArtifact("_dx/top/shard25.jar", topTarget)); assertThat(shardAction.getArguments()).contains("--main_dex_filter"); assertThat(ActionsTestUtil.baseArtifactNames(getNonToolInputs(shardAction))) .containsExactly("top_proguard.jar", "main_dex_list.txt"); SpawnAction mergeAction = getGeneratingSpawnAction(getBinArtifact("_dx/top/shard1.jar.dex.zip", topTarget)); assertThat(mergeAction.getArguments()).doesNotContain("--main-dex-list"); assertThat(ActionsTestUtil.baseArtifactNames(getNonToolInputs(mergeAction))) .contains("shard1.jar"); } @Test public void testIncrementalDexingAfterProguard_autoShardedMonodex() throws Exception { useConfiguration("--experimental_incremental_dexing_after_proguard=3"); // Use "legacy" multidex mode so we get a main dex list file and can test that it's passed to // the splitter action (similar to _withDexShards below), unlike without the dex splitter where // the main dex list goes to the merging action. scratch.file( "java/com/google/android/BUILD", "android_binary(", " name = 'top',", " srcs = ['foo.java', 'bar.srcjar'],", " manifest = 'AndroidManifest.xml',", " incremental_dexing = 1,", " multidex = 'off',", " proguard_specs = ['b.pro'],", ")"); ConfiguredTarget topTarget = getConfiguredTarget("//java/com/google/android:top"); assertNoEvents(); SpawnAction mergeAction = getGeneratingSpawnAction(getBinArtifact("_dx/top/classes.dex.zip", topTarget)); assertThat(mergeAction.getArguments()).doesNotContain("--main-dex-list"); assertThat(ActionsTestUtil.baseArtifactNames(getNonToolInputs(mergeAction))) .containsExactly("shard1.jar.dex.zip", "shard2.jar.dex.zip", "shard3.jar.dex.zip"); SpawnAction shuffleAction = getGeneratingSpawnAction(getBinArtifact("_dx/top/shard1.jar", topTarget)); assertThat(shuffleAction.getArguments()).doesNotContain("--main-dex-list"); assertThat(ActionsTestUtil.baseArtifactNames(getNonToolInputs(shuffleAction))) .containsExactly("top_proguard.jar"); } @Test public void testV1SigningMethod() throws Exception { actualSignerToolTests("v1", "true", "false"); } @Test public void testV2SigningMethod() throws Exception { actualSignerToolTests("v2", "false", "true"); } @Test public void testV1V2SigningMethod() throws Exception { actualSignerToolTests("v1_v2", "true", "true"); } private void actualSignerToolTests(String apkSigningMethod, String signV1, String signV2) throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_binary(name = 'hello',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',)"); useConfiguration("--apk_signing_method=" + apkSigningMethod); ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android/hello:hello"); Set<Artifact> artifacts = actionsTestUtil().artifactClosureOf(getFilesToBuild(binary)); assertThat(getFirstArtifactEndingWith(artifacts, "signed_hello.apk")).isNull(); SpawnAction unsignedApkAction = (SpawnAction) actionsTestUtil() .getActionForArtifactEndingWith(artifacts, "/hello_unsigned.apk"); assertThat( Streams.stream(unsignedApkAction.getInputs()) .map(Artifact::getFilename) .anyMatch(filename -> Ascii.toLowerCase(filename).contains("singlejar"))) .isTrue(); SpawnAction compressedUnsignedApkAction = (SpawnAction) actionsTestUtil() .getActionForArtifactEndingWith(artifacts, "compressed_hello_unsigned.apk"); assertThat( Streams.stream(compressedUnsignedApkAction.getInputs()) .map(Artifact::getFilename) .anyMatch(filename -> Ascii.toLowerCase(filename).contains("singlejar"))) .isTrue(); SpawnAction zipalignAction = (SpawnAction) actionsTestUtil() .getActionForArtifactEndingWith(artifacts, "zipaligned_hello.apk"); assertThat(zipalignAction.getCommandFilename()).endsWith("zipalign"); Artifact a = ActionsTestUtil.getFirstArtifactEndingWith(artifacts, "hello.apk"); assertThat(getGeneratingSpawnAction(a).getCommandFilename()).endsWith("ApkSignerBinary"); List<String> args = getGeneratingSpawnActionArgs(a); assertThat(flagValue("--v1-signing-enabled", args)).isEqualTo(signV1); assertThat(flagValue("--v2-signing-enabled", args)).isEqualTo(signV2); } @Test public void testResourceShrinkingAction() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_binary(name = 'hello',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " inline_constants = 0,", " resource_files = ['res/values/strings.xml'],", " shrink_resources = 1,", " resource_configuration_filters = ['en'],", " proguard_specs = ['proguard-spec.pro'],)"); ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android/hello:hello"); Set<Artifact> artifacts = actionsTestUtil().artifactClosureOf(getFilesToBuild(binary)); assertThat(artifacts) .containsAtLeast( getFirstArtifactEndingWith(artifacts, "resource_files.zip"), getFirstArtifactEndingWith(artifacts, "proguard.jar"), getFirstArtifactEndingWith(artifacts, "shrunk.ap_")); List<String> processingArgs = getGeneratingSpawnActionArgs(getFirstArtifactEndingWith(artifacts, "resource_files.zip")); assertThat(flagValue("--resourcesOutput", processingArgs)) .endsWith("hello_files/resource_files.zip"); List<String> proguardArgs = getGeneratingSpawnActionArgs(getFirstArtifactEndingWith(artifacts, "proguard.jar")); assertThat(flagValue("-outjars", proguardArgs)).endsWith("hello_proguard.jar"); List<String> shrinkingArgs = getGeneratingSpawnActionArgs(getFirstArtifactEndingWith(artifacts, "shrunk.ap_")); assertThat(flagValue("--resources", shrinkingArgs)) .isEqualTo(flagValue("--resourcesOutput", processingArgs)); assertThat(flagValue("--shrunkJar", shrinkingArgs)) .isEqualTo(flagValue("-outjars", proguardArgs)); assertThat(flagValue("--proguardMapping", shrinkingArgs)) .isEqualTo(flagValue("-printmapping", proguardArgs)); assertThat(flagValue("--rTxt", shrinkingArgs)) .isEqualTo(flagValue("--rOutput", processingArgs)); assertThat(flagValue("--primaryManifest", shrinkingArgs)) .isEqualTo(flagValue("--manifestOutput", processingArgs)); assertThat(flagValue("--resourceConfigs", shrinkingArgs)) .isEqualTo(flagValue("--resourceConfigs", processingArgs)); List<String> packageArgs = getGeneratingSpawnActionArgs(getFirstArtifactEndingWith(artifacts, "_hello_proguard.cfg")); assertThat(flagValue("--tool", packageArgs)).isEqualTo("PACKAGE"); assertThat(packageArgs).doesNotContain("--conditionalKeepRules"); } @Test public void testResourceCycleShrinking() throws Exception { useConfiguration("--experimental_android_resource_cycle_shrinking=true"); checkError( "java/a", "a", "resource cycle shrinking can only be enabled for builds with aapt2", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = [ 'res/values/values.xml' ], ", " shrink_resources = 1,", ")"); } @Test public void testResourceCycleShrinkingWithoutResourceShinking() throws Exception { useConfiguration("--experimental_android_resource_cycle_shrinking=true"); checkError( "java/a", "a", "resource cycle shrinking can only be enabled when resource shrinking is enabled", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = [ 'res/values/values.xml' ], ", " shrink_resources = 0,", ")"); } @Test public void testResourceShrinking_RequiresProguard() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_binary(name = 'hello',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " inline_constants = 0,", " resource_files = ['res/values/strings.xml'],", " shrink_resources = 1,)"); ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android/hello:hello"); Set<Artifact> artifacts = actionsTestUtil().artifactClosureOf(getFilesToBuild(binary)); assertThat(artifacts).containsNoneOf( getFirstArtifactEndingWith(artifacts, "shrunk.jar"), getFirstArtifactEndingWith(artifacts, "shrunk.ap_")); } @Test public void testProguardExtraOutputs() throws Exception { scratch.file( "java/com/google/android/hello/BUILD", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard-spec.pro'])"); ConfiguredTarget output = getConfiguredTarget("//java/com/google/android/hello:b"); // Checks that ProGuard is called with the appropriate options. Artifact a = getFirstArtifactEndingWith(getFilesToBuild(output), "_proguard.jar"); SpawnAction action = getGeneratingSpawnAction(a); List<String> args = getGeneratingSpawnActionArgs(a); // Assert that the ProGuard executable set in the android_sdk rule appeared in the command-line // of the SpawnAction that generated the _proguard.jar. assertThat( Iterables.any( args, new Predicate<String>() { @Override public boolean apply(String s) { return s.endsWith("ProGuard"); } })) .isTrue(); assertThat(args) .containsAtLeast( "-injars", execPathEndingWith(action.getInputs(), "b_deploy.jar"), "-printseeds", execPathEndingWith(action.getOutputs(), "b_proguard.seeds"), "-printusage", execPathEndingWith(action.getOutputs(), "b_proguard.usage")) .inOrder(); // Checks that the output files are produced. assertProguardUsed(output); assertThat(getBinArtifact("b_proguard.usage", output)).isNotNull(); assertThat(getBinArtifact("b_proguard.seeds", output)).isNotNull(); } @Test public void testProGuardExecutableMatchesConfiguration() throws Exception { scratch.file("java/com/google/devtools/build/jkrunchy/BUILD", "package(default_visibility=['//visibility:public'])", "java_binary(name = 'jkrunchy',", " srcs = glob(['*.java']),", " main_class = 'com.google.devtools.build.jkrunchy.JKrunchyMain')"); useConfiguration("--proguard_top=//java/com/google/devtools/build/jkrunchy:jkrunchy"); scratch.file("java/com/google/android/hello/BUILD", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard-spec.pro'])"); ConfiguredTarget output = getConfiguredTarget("//java/com/google/android/hello:b_proguard.jar"); assertProguardUsed(output); SpawnAction proguardAction = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( getFilesToBuild(output), "_proguard.jar"); Artifact jkrunchyExecutable = getHostConfiguredTarget("//java/com/google/devtools/build/jkrunchy") .getProvider(FilesToRunProvider.class) .getExecutable(); assertWithMessage("ProGuard implementation was not correctly taken from the configuration") .that(proguardAction.getCommandFilename()) .isEqualTo(jkrunchyExecutable.getExecPathString()); } @Test public void testNeverlinkTransitivity() throws Exception { useConfiguration("--android_fixed_resource_neverlinking"); scratch.file( "java/com/google/android/neversayneveragain/BUILD", "android_library(name = 'l1',", " srcs = ['l1.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/values/resource.xml'])", "android_library(name = 'l2',", " srcs = ['l2.java'],", " deps = [':l1'],", " neverlink = 1)", "android_library(name = 'l3',", " srcs = ['l3.java'],", " deps = [':l2'])", "android_library(name = 'l4',", " srcs = ['l4.java'],", " deps = [':l1'])", "android_binary(name = 'b1',", " srcs = ['b1.java'],", " deps = [':l2'],", " manifest = 'AndroidManifest.xml')", "android_binary(name = 'b2',", " srcs = ['b2.java'],", " deps = [':l3'],", " manifest = 'AndroidManifest.xml')", "android_binary(name = 'b3',", " srcs = ['b3.java'],", " deps = [':l3', ':l4'],", " manifest = 'AndroidManifest.xml')"); ConfiguredTarget b1 = getConfiguredTarget("//java/com/google/android/neversayneveragain:b1"); Action b1DeployAction = actionsTestUtil().getActionForArtifactEndingWith( actionsTestUtil().artifactClosureOf(getFilesToBuild(b1)), "b1_deploy.jar"); List<String> b1Inputs = prettyArtifactNames(b1DeployAction.getInputs()); assertThat(b1Inputs).containsNoneOf( "java/com/google/android/neversayneveragain/libl1.jar_desugared.jar", "java/com/google/android/neversayneveragain/libl2.jar_desugared.jar", "java/com/google/android/neversayneveragain/libl3.jar_desugared.jar", "java/com/google/android/neversayneveragain/libl4.jar_desugared.jar"); assertThat(b1Inputs).contains( "java/com/google/android/neversayneveragain/libb1.jar_desugared.jar"); assertThat( resourceInputPaths( "java/com/google/android/neversayneveragain", getValidatedResources(b1))) .doesNotContain("res/values/resource.xml"); ConfiguredTarget b2 = getConfiguredTarget("//java/com/google/android/neversayneveragain:b2"); Action b2DeployAction = actionsTestUtil().getActionForArtifactEndingWith( actionsTestUtil().artifactClosureOf(getFilesToBuild(b2)), "b2_deploy.jar"); List<String> b2Inputs = prettyArtifactNames(b2DeployAction.getInputs()); assertThat(b2Inputs).containsNoneOf( "java/com/google/android/neversayneveragain/libl1.jar_desugared.jar", "java/com/google/android/neversayneveragain/libl2.jar_desugared.jar", "java/com/google/android/neversayneveragain/libl4.jar_desugared.jar"); assertThat(b2Inputs) .containsAtLeast( "java/com/google/android/neversayneveragain/_dx/l3/libl3.jar_desugared.jar", "java/com/google/android/neversayneveragain/libb2.jar_desugared.jar"); assertThat( resourceInputPaths( "java/com/google/android/neversayneveragain", getValidatedResources(b2))) .doesNotContain("res/values/resource.xml"); ConfiguredTarget b3 = getConfiguredTarget("//java/com/google/android/neversayneveragain:b3"); Action b3DeployAction = actionsTestUtil().getActionForArtifactEndingWith( actionsTestUtil().artifactClosureOf(getFilesToBuild(b3)), "b3_deploy.jar"); List<String> b3Inputs = prettyArtifactNames(b3DeployAction.getInputs()); assertThat(b3Inputs) .containsAtLeast( "java/com/google/android/neversayneveragain/_dx/l1/libl1.jar_desugared.jar", "java/com/google/android/neversayneveragain/_dx/l3/libl3.jar_desugared.jar", "java/com/google/android/neversayneveragain/_dx/l4/libl4.jar_desugared.jar", "java/com/google/android/neversayneveragain/libb3.jar_desugared.jar"); assertThat(b3Inputs) .doesNotContain("java/com/google/android/neversayneveragain/libl2.jar_desugared.jar"); assertThat( resourceInputPaths( "java/com/google/android/neversayneveragain", getValidatedResources(b3))) .contains("res/values/resource.xml"); } @Test public void testDexopts() throws Exception { useConfiguration("--noincremental_dexing"); checkDexopts("[ '--opt1', '--opt2' ]", ImmutableList.of("--opt1", "--opt2")); } @Test public void testDexoptsTokenization() throws Exception { useConfiguration("--noincremental_dexing"); checkDexopts("[ '--opt1', '--opt2 tokenized' ]", ImmutableList.of("--opt1", "--opt2", "tokenized")); } @Test public void testDexoptsMakeVariableSubstitution() throws Exception { useConfiguration("--noincremental_dexing"); checkDexopts("[ '--opt1', '$(COMPILATION_MODE)' ]", ImmutableList.of("--opt1", "fastbuild")); } private void checkDexopts(String dexopts, List<String> expectedArgs) throws Exception { scratch.file("java/com/google/android/BUILD", "android_binary(name = 'b',", " srcs = ['dummy1.java'],", " dexopts = " + dexopts + ",", " manifest = 'AndroidManifest.xml')"); // Include arguments that are always included. List<String> fixedArgs = ImmutableList.of("--num-threads=5"); expectedArgs = new ImmutableList.Builder<String>() .addAll(fixedArgs).addAll(expectedArgs).build(); // Ensure that the args that immediately follow "--dex" match the expectation. ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android:b"); List<String> args = getGeneratingSpawnActionArgs( ActionsTestUtil.getFirstArtifactEndingWith( actionsTestUtil().artifactClosureOf(getFilesToBuild(binary)), "classes.dex")); int start = args.indexOf("--dex") + 1; assertThat(start).isNotEqualTo(0); int end = Math.min(args.size(), start + expectedArgs.size()); assertThat(args.subList(start, end)).isEqualTo(expectedArgs); } @Test public void testDexMainListOpts() throws Exception { checkDexMainListOpts("[ '--opt1', '--opt2' ]", "--opt1", "--opt2"); } @Test public void testDexMainListOptsTokenization() throws Exception { checkDexMainListOpts("[ '--opt1', '--opt2 tokenized' ]", "--opt1", "--opt2", "tokenized"); } @Test public void testDexMainListOptsMakeVariableSubstitution() throws Exception { checkDexMainListOpts("[ '--opt1', '$(COMPILATION_MODE)' ]", "--opt1", "fastbuild"); } private void checkDexMainListOpts(String mainDexListOpts, String... expectedArgs) throws Exception { scratch.file("java/com/google/android/BUILD", "android_binary(name = 'b',", " srcs = ['dummy1.java'],", " multidex = \"legacy\",", " main_dex_list_opts = " + mainDexListOpts + ",", " manifest = 'AndroidManifest.xml')"); // Ensure that the args that immediately follow the main class in the shell command // match the expectation. ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android:b"); List<String> args = getGeneratingSpawnActionArgs( ActionsTestUtil.getFirstArtifactEndingWith( actionsTestUtil().artifactClosureOf(getFilesToBuild(binary)), "main_dex_list.txt")); // args: [ "bash", "-c", "java -cp dx.jar main opts other" ] MoreAsserts.assertContainsSublist(args, expectedArgs); } @Test public void testResourceConfigurationFilters() throws Exception { scratch.file("java/com/google/android/BUILD", "android_binary(name = 'b',", " srcs = ['dummy1.java'],", " manifest = 'AndroidManifest.xml',", " resource_configuration_filters = [ 'en', 'fr'],)"); // Ensure that the args are present ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android:b"); List<String> args = resourceArguments(getValidatedResources(binary)); assertThat(flagValue("--resourceConfigs", args)).contains("en,fr"); } @Test public void testFilteredResourcesInvalidFilter() throws Exception { String badQualifier = "invalid-qualifier"; checkError( "java/r/android", "r", badQualifier, "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/values/foo.xml'],", " resource_configuration_filters = ['" + badQualifier + "'])"); } @Test public void testFilteredResourcesInvalidResourceDir() throws Exception { String badQualifierDir = "values-invalid-qualifier"; checkError( "java/r/android", "r", badQualifierDir, "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/" + badQualifierDir + "/foo.xml'],", " resource_configuration_filters = ['en'])"); } /** Test that resources are not filtered in analysis under aapt2. */ @Test public void testFilteredResourcesFilteringAapt2() throws Exception { List<String> resources = ImmutableList.of("res/values/foo.xml", "res/values-en/foo.xml", "res/values-fr/foo.xml"); String dir = "java/r/android"; mockAndroidSdkWithAapt2(); useConfiguration("--android_sdk=//sdk:sdk"); ConfiguredTarget binary = scratchConfiguredTarget( dir, "r", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_configuration_filters = ['', 'en, es, '],", " aapt_version = 'aapt2',", " densities = ['hdpi, , ', 'xhdpi'],", " resource_files = ['" + Joiner.on("', '").join(resources) + "'])"); ValidatedAndroidResources directResources = getValidatedResources(binary, /* transitive= */ false); // Validate that the AndroidResourceProvider for this binary contains all values. assertThat(resourceContentsPaths(dir, directResources)).containsExactlyElementsIn(resources); // Validate that the input to resource processing contains all values. assertThat(resourceInputPaths(dir, directResources)).containsAtLeastElementsIn(resources); // Validate that the filters are correctly passed to the resource processing action // This includes trimming whitespace and ignoring empty filters. assertThat(resourceArguments(directResources)).contains("en,es"); assertThat(resourceArguments(directResources)).contains("hdpi,xhdpi"); } @Test public void testFilteredResourcesSimple() throws Exception { testDirectResourceFiltering( "en", /* unexpectedQualifiers= */ ImmutableList.of("fr"), /* expectedQualifiers= */ ImmutableList.of("en")); } @Test public void testFilteredResourcesNoopFilter() throws Exception { testDirectResourceFiltering( /* filters= */ "", /* unexpectedQualifiers= */ ImmutableList.<String>of(), /* expectedQualifiers= */ ImmutableList.of("en", "fr")); } @Test public void testFilteredResourcesMultipleFilters() throws Exception { testDirectResourceFiltering( "en,es", /* unexpectedQualifiers= */ ImmutableList.of("fr"), /* expectedQualifiers= */ ImmutableList.of("en", "es")); } @Test public void testFilteredResourcesMultipleFiltersWithWhitespace() throws Exception { testDirectResourceFiltering( " en , es ", /* unexpectedQualifiers= */ ImmutableList.of("fr"), /* expectedQualifiers= */ ImmutableList.of("en", "es")); } @Test public void testFilteredResourcesMultipleFilterStrings() throws Exception { testDirectResourceFiltering( "en', 'es", /* unexpectedQualifiers= */ ImmutableList.of("fr"), /* expectedQualifiers= */ ImmutableList.of("en", "es")); } @Test public void testFilteredResourcesLocaleWithoutRegion() throws Exception { testDirectResourceFiltering( "en", /* unexpectedQualifiers= */ ImmutableList.of("fr-rCA"), /* expectedQualifiers= */ ImmutableList.of("en-rCA", "en-rUS", "en")); } @Test public void testFilteredResourcesLocaleWithRegion() throws Exception { testDirectResourceFiltering( "en-rUS", /* unexpectedQualifiers= */ ImmutableList.of("en-rGB"), /* expectedQualifiers= */ ImmutableList.of("en-rUS", "en")); } @Test public void testFilteredResourcesOldAaptLocale() throws Exception { testDirectResourceFiltering( "en_US,fr_CA", /* unexpectedQualifiers= */ ImmutableList.of("en-rCA"), /* expectedQualifiers = */ ImmutableList.of("en-rUS", "fr-rCA")); } @Test public void testFilteredResourcesOldAaptLocaleOtherQualifiers() throws Exception { testDirectResourceFiltering( "mcc310-en_US-ldrtl,mcc311-mnc312-fr_CA", /* unexpectedQualifiers= */ ImmutableList.of("en-rCA", "mcc312", "mcc311-mnc311"), /* expectedQualifiers = */ ImmutableList.of("en-rUS", "fr-rCA", "mcc310", "mcc311-mnc312")); } @Test public void testFilteredResourcesSmallestScreenWidth() throws Exception { testDirectResourceFiltering( "sw600dp", /* unexpectedQualifiers= */ ImmutableList.of("sw700dp"), /* expectedQualifiers= */ ImmutableList.of("sw500dp", "sw600dp")); } @Test public void testFilteredResourcesScreenWidth() throws Exception { testDirectResourceFiltering( "w600dp", /* unexpectedQualifiers= */ ImmutableList.of("w700dp"), /* expectedQualifiers= */ ImmutableList.of("w500dp", "w600dp")); } @Test public void testFilteredResourcesScreenHeight() throws Exception { testDirectResourceFiltering( "h600dp", /* unexpectedQualifiers= */ ImmutableList.of("h700dp"), /* expectedQualifiers= */ ImmutableList.of("h500dp", "h600dp")); } @Test public void testFilteredResourcesScreenSize() throws Exception { testDirectResourceFiltering( "normal", /* unexpectedQualifiers= */ ImmutableList.of("large", "xlarge"), /* expectedQualifiers= */ ImmutableList.of("small", "normal")); } /** Tests that filtering on density is ignored to match aapt behavior. */ @Test public void testFilteredResourcesDensity() throws Exception { testDirectResourceFiltering( "hdpi", /* unexpectedQualifiers= */ ImmutableList.<String>of(), /* expectedQualifiers= */ ImmutableList.of("ldpi", "mdpi", "hdpi", "xhdpi", "xxhdpi")); } /** Tests that filtering on API version is ignored to match aapt behavior. */ @Test public void testFilteredResourcesApiVersion() throws Exception { testDirectResourceFiltering( "v4", /* unexpectedQualifiers= */ ImmutableList.<String>of(), /* expectedQualifiers= */ ImmutableList.of("v3", "v4", "v5")); } @Test public void testFilteredResourcesRegularQualifiers() throws Exception { // Include one value for each qualifier not tested above String filters = "mcc310-mnc004-ldrtl-long-round-port-car-night-notouch-keysexposed-nokeys-navexposed-nonav"; // In the qualifiers we expect to be removed, include one value that contradicts each qualifier // of the filter testDirectResourceFiltering( filters, /* unexpectedQualifiers= */ ImmutableList.of( "mcc309", "mnc03", "ldltr", "notlong", "notround", "land", "watch", "notnight", "finger", "keyshidden", "qwerty", "navhidden", "dpad"), /* expectedQualifiers= */ ImmutableList.of(filters)); } @Test public void testDensityFilteredResourcesSingleDensity() throws Exception { testDensityResourceFiltering( "hdpi", ImmutableList.of("ldpi", "mdpi", "xhdpi"), ImmutableList.of("hdpi")); } @Test public void testDensityFilteredResourcesSingleClosestDensity() throws Exception { testDensityResourceFiltering( "hdpi", ImmutableList.of("ldpi", "mdpi"), ImmutableList.of("xhdpi")); } @Test public void testDensityFilteredResourcesDifferingQualifiers() throws Exception { testDensityResourceFiltering( "hdpi", ImmutableList.of("en-xhdpi", "fr"), ImmutableList.of("en-hdpi", "fr-mdpi", "xhdpi")); } @Test public void testDensityFilteredResourcesMultipleDensities() throws Exception { testDensityResourceFiltering( "hdpi,ldpi,xhdpi", ImmutableList.of("mdpi", "xxhdpi"), ImmutableList.of("ldpi", "hdpi", "xhdpi")); } @Test public void testDensityFilteredResourcesDoubledDensity() throws Exception { testDensityResourceFiltering( "hdpi", ImmutableList.of("ldpi", "mdpi", "xhdpi"), ImmutableList.of("xxhdpi")); } @Test public void testDensityFilteredResourcesDifferentRatiosSmallerCloser() throws Exception { testDensityResourceFiltering("mdpi", ImmutableList.of("hdpi"), ImmutableList.of("ldpi")); } @Test public void testDensityFilteredResourcesDifferentRatiosLargerCloser() throws Exception { testDensityResourceFiltering("hdpi", ImmutableList.of("mdpi"), ImmutableList.of("xhdpi")); } @Test public void testDensityFilteredResourcesSameRatioPreferLarger() throws Exception { // xxhdpi is 480dpi and xxxhdpi is 640dpi. // The ratios between 360dpi and 480dpi and between 480dpi and 640dpi are both 3:4. testDensityResourceFiltering("xxhdpi", ImmutableList.of("360dpi"), ImmutableList.of("xxxhdpi")); } @Test public void testDensityFilteredResourcesOptionsSmallerThanDesired() throws Exception { testDensityResourceFiltering( "xxxhdpi", ImmutableList.of("xhdpi", "mdpi", "ldpi"), ImmutableList.of("xxhdpi")); } @Test public void testDensityFilteredResourcesOptionsLargerThanDesired() throws Exception { testDensityResourceFiltering( "ldpi", ImmutableList.of("xxxhdpi", "xxhdpi", "xhdpi"), ImmutableList.of("mdpi")); } @Test public void testDensityFilteredResourcesSpecialValues() throws Exception { testDensityResourceFiltering( "xxxhdpi", ImmutableList.of("anydpi", "nodpi"), ImmutableList.of("ldpi")); } @Test public void testDensityFilteredResourcesXml() throws Exception { testDirectResourceFiltering( /* resourceConfigurationFilters= */ "", "hdpi", ImmutableList.<String>of(), ImmutableList.of("ldpi", "mdpi", "hdpi", "xhdpi"), /* expectUnqualifiedResource= */ true, "drawable", "xml"); } @Test public void testDensityFilteredResourcesNotDrawable() throws Exception { testDirectResourceFiltering( /* resourceConfigurationFilters= */ "", "hdpi", ImmutableList.<String>of(), ImmutableList.of("ldpi", "mdpi", "hdpi", "xhdpi"), /* expectUnqualifiedResource= */ true, "layout", "png"); } @Test public void testQualifierAndDensityFilteredResources() throws Exception { testDirectResourceFiltering( "en,fr-mdpi", "hdpi,ldpi", ImmutableList.of("mdpi", "es-ldpi", "en-xxxhdpi", "fr-mdpi"), ImmutableList.of("ldpi", "hdpi", "en-xhdpi", "fr-hdpi"), /* expectUnqualifiedResource= */ false, "drawable", "png"); } private void testDensityResourceFiltering( String densities, List<String> unexpectedQualifiers, List<String> expectedQualifiers) throws Exception { testDirectResourceFiltering( /* resourceConfigurationFilters= */ "", densities, unexpectedQualifiers, expectedQualifiers, /* expectUnqualifiedResource= */ false, "drawable", "png"); } private void testDirectResourceFiltering( String filters, List<String> unexpectedQualifiers, ImmutableList<String> expectedQualifiers) throws Exception { testDirectResourceFiltering( filters, /* densities= */ "", unexpectedQualifiers, expectedQualifiers, /* expectUnqualifiedResource= */ true, "drawable", "png"); } private void testDirectResourceFiltering( String resourceConfigurationFilters, String densities, List<String> unexpectedQualifiers, List<String> expectedQualifiers, boolean expectUnqualifiedResource, String folderType, String suffix) throws Exception { List<String> unexpectedResources = new ArrayList<>(); for (String qualifier : unexpectedQualifiers) { unexpectedResources.add("res/" + folderType + "-" + qualifier + "/foo." + suffix); } List<String> expectedResources = new ArrayList<>(); for (String qualifier : expectedQualifiers) { expectedResources.add("res/" + folderType + "-" + qualifier + "/foo." + suffix); } String unqualifiedResource = "res/" + folderType + "/foo." + suffix; if (expectUnqualifiedResource) { expectedResources.add(unqualifiedResource); } else { unexpectedResources.add(unqualifiedResource); } // Default resources should never be filtered expectedResources.add("res/values/foo.xml"); Iterable<String> allResources = Iterables.concat(unexpectedResources, expectedResources); String dir = "java/r/android"; ConfiguredTarget binary = scratchConfiguredTarget( dir, "r", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_configuration_filters = ['" + resourceConfigurationFilters + "'],", " densities = ['" + densities + "'],", " resource_files = ['" + Joiner.on("', '").join(allResources) + "'])"); // No prefix should be added because of resource filtering. assertThat( getConfiguration(binary) .getFragment(AndroidConfiguration.class) .getOutputDirectoryName()) .isNull(); ValidatedAndroidResources directResources = getValidatedResources(binary, /* transitive= */ false); // Validate that the AndroidResourceProvider for this binary contains only the filtered values. assertThat(resourceContentsPaths(dir, directResources)) .containsExactlyElementsIn(expectedResources); // Validate that the input to resource processing contains only the filtered values. assertThat(resourceInputPaths(dir, directResources)) .containsAtLeastElementsIn(expectedResources); assertThat(resourceInputPaths(dir, directResources)).containsNoneIn(unexpectedResources); // Only transitive resources need to be ignored when filtered,, and there aren't any here. assertThat(resourceArguments(directResources)).doesNotContain("--prefilteredResources"); // Validate resource filters are passed to execution List<String> args = resourceArguments(directResources); // Remove whitespace and quotes from the resourceConfigurationFilters attribute value to get the // value we expect to pass to the resource processing action String fixedResourceConfigFilters = resourceConfigurationFilters.replaceAll("[ ']", ""); if (resourceConfigurationFilters.isEmpty()) { assertThat(args).containsNoneOf("--resourceConfigs", fixedResourceConfigFilters); } else { assertThat(args).containsAtLeast("--resourceConfigs", fixedResourceConfigFilters).inOrder(); } if (densities.isEmpty()) { assertThat(args).containsNoneOf("--densities", densities); } else { // We still expect densities only for the purposes of adding information to manifests assertThat(args).containsAtLeast("--densities", densities).inOrder(); } } @Test public void testFilteredTransitiveResources() throws Exception { String matchingResource = "res/values-en/foo.xml"; String unqualifiedResource = "res/values/foo.xml"; String notMatchingResource = "res/values-fr/foo.xml"; String dir = "java/r/android"; ConfiguredTarget binary = scratchConfiguredTarget( dir, "r", "android_library(name = 'lib',", " manifest = 'AndroidManifest.xml',", " resource_files = [", " '" + matchingResource + "',", " '" + unqualifiedResource + "',", " '" + notMatchingResource + "'", " ])", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " deps = [':lib'],", " resource_configuration_filters = ['en'])"); ValidatedAndroidResources directResources = getValidatedResources(binary, /* transitive= */ false); ValidatedAndroidResources transitiveResources = getValidatedResources(binary, /* transitive= */ true); assertThat(resourceContentsPaths(dir, directResources)).isEmpty(); assertThat(resourceContentsPaths(dir, transitiveResources)) .containsExactly(matchingResource, unqualifiedResource); assertThat(resourceInputPaths(dir, directResources)) .containsExactly(matchingResource, unqualifiedResource); String[] flagValues = flagValue("--prefilteredResources", resourceArguments(directResources)).split(","); assertThat(flagValues).asList().containsExactly("values-fr/foo.xml"); } @Test public void testFilteredTransitiveResourcesDifferentDensities() throws Exception { String dir = "java/r/android"; ConfiguredTarget binary = scratchConfiguredTarget( dir, "bin", "android_binary(name = 'bin',", " manifest = 'AndroidManifest.xml',", " resource_configuration_filters = ['en'],", " densities = ['hdpi'],", " deps = [':invalid', ':best', ':other', ':multiple'],", ")", "android_library(name = 'invalid',", " manifest = 'AndroidManifest.xml',", " resource_files = ['invalid/res/drawable-fr-hdpi/foo.png'],", ")", "android_library(name = 'best',", " manifest = 'AndroidManifest.xml',", " resource_files = ['best/res/drawable-en-hdpi/foo.png'],", ")", "android_library(name = 'other',", " manifest = 'AndroidManifest.xml',", " resource_files = ['other/res/drawable-en-mdpi/foo.png'],", ")", "android_library(name = 'multiple',", " manifest = 'AndroidManifest.xml',", " resource_files = [", " 'multiple/res/drawable-en-hdpi/foo.png',", " 'multiple/res/drawable-en-mdpi/foo.png'],", ")"); ValidatedAndroidResources directResources = getValidatedResources(binary, /* transitive= */ false); // All of the resources are transitive assertThat(resourceContentsPaths(dir, directResources)).isEmpty(); // Only the best matches should be used. This includes multiple best matches, even given a // single density filter, since they are each from a different dependency. This duplication // would be resolved during merging. assertThat(resourceInputPaths(dir, directResources)) .containsExactly( "best/res/drawable-en-hdpi/foo.png", "multiple/res/drawable-en-hdpi/foo.png"); } @Test public void testFilteredResourcesAllFilteredOut() throws Exception { String dir = "java/r/android"; final String keptBaseDir = "partly_filtered_dir"; String removedLibraryDir = "fully_filtered_library_dir"; String removedBinaryDir = "fully_filtered_binary_dir"; ConfiguredTarget binary = scratchConfiguredTarget( dir, "bin", "android_library(name = 'not_fully_filtered_lib',", " manifest = 'AndroidManifest.xml',", " resource_files = [", // Some of the resources in this directory are kept: " '" + keptBaseDir + "/values-es/foo.xml',", " '" + keptBaseDir + "/values-fr/foo.xml',", " '" + keptBaseDir + "/values-en/foo.xml',", " ])", "android_library(name = 'fully_filtered_lib',", " manifest = 'AndroidManifest.xml',", " resource_files = [", // All of the resources in this directory are filtered out: " '" + removedLibraryDir + "/values-es/foo.xml',", " '" + removedLibraryDir + "/values-fr/foo.xml',", " ])", "android_binary(name = 'bin',", " manifest = 'AndroidManifest.xml',", " resource_configuration_filters = ['en'],", " resource_files = [", // All of the resources in this directory are filtered out: " '" + removedBinaryDir + "/values-es/foo.xml',", " '" + removedBinaryDir + "/values-fr/foo.xml',", " ],", " deps = [", " ':fully_filtered_lib',", " ':not_fully_filtered_lib',", " ])"); List<String> resourceProcessingArgs = getGeneratingSpawnActionArgs(getValidatedResources(binary).getRTxt()); assertThat( Iterables.filter( resourceProcessingArgs, new Predicate<String>() { @Override public boolean apply(String input) { return input.contains(keptBaseDir); } })) .isNotEmpty(); for (String arg : resourceProcessingArgs) { assertThat(arg).doesNotContain(removedLibraryDir); assertThat(arg).doesNotContain(removedBinaryDir); } } @Test public void testFilterResourcesPseudolocalesPropagated() throws Exception { String dir = "java/r/android"; ConfiguredTarget binary = scratchConfiguredTarget( dir, "bin", "android_binary(name = 'bin',", " resource_files = glob(['res/**']),", " resource_configuration_filters = ['en', 'en-rXA', 'ar-rXB'],", " manifest = 'AndroidManifest.xml')"); List<String> resourceProcessingArgs = getGeneratingSpawnActionArgs(getValidatedResources(binary).getRTxt()); assertThat(resourceProcessingArgs).containsAtLeast("--resourceConfigs", "ar-rXB,en,en-rXA"); } @Test public void testThrowOnResourceConflictFlagGetsPropagated() throws Exception { scratch.file( "java/r/android/BUILD", "android_binary(", " name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/values/foo.xml'],", ")"); useConfiguration("--experimental_android_throw_on_resource_conflict"); ConfiguredTarget binary = getConfiguredTarget("//java/r/android:r"); List<String> resourceProcessingArgs = resourceArguments(getValidatedResources(binary)); assertThat(resourceProcessingArgs).contains("--throwOnResourceConflict"); } /** * Gets the paths of matching artifacts contained within a resource container * * @param dir the directory to look for artifacts in * @param resource the container that contains eligible artifacts * @return the paths to all artifacts from the input that are contained within the given * directory, relative to that directory. */ private List<String> resourceContentsPaths(String dir, ValidatedAndroidResources resource) { return pathsToArtifacts(dir, resource.getArtifacts()); } /** * Gets the paths of matching artifacts that are used as input to resource processing * * @param dir the directory to look for artifacts in * @param resource the output from the resource processing that uses these artifacts as inputs * @return the paths to all artifacts used as inputs to resource processing that are contained * within the given directory, relative to that directory. */ private List<String> resourceInputPaths(String dir, ValidatedAndroidResources resource) { return pathsToArtifacts(dir, resourceGeneratingAction(resource).getInputs()); } /** * Gets the paths of matching artifacts from an iterable * * @param dir the directory to look for artifacts in * @param artifacts all available artifacts * @return the paths to all artifacts from the input that are contained within the given * directory, relative to that directory. */ private List<String> pathsToArtifacts(String dir, Iterable<Artifact> artifacts) { List<String> paths = new ArrayList<>(); Path containingDir = rootDirectory; for (String part : dir.split("/")) { containingDir = containingDir.getChild(part); } for (Artifact a : artifacts) { if (a.getPath().startsWith(containingDir)) { paths.add(a.getPath().relativeTo(containingDir).toString()); } } return paths; } @Test public void testInheritedRNotInRuntimeJars() throws Exception { String dir = "java/r/android/"; scratch.file( dir + "BUILD", "android_library(name = 'sublib',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res3/**']),", " srcs =['sublib.java'],", " )", "android_library(name = 'lib',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res2/**']),", " deps = [':sublib'],", " srcs =['lib.java'],", " )", "android_binary(name = 'bin',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res/**']),", " deps = [':lib'],", " srcs =['bin.java'],", " )"); Action deployJarAction = getGeneratingAction( getFileConfiguredTarget("//java/r/android:bin_deploy.jar").getArtifact()); List<String> inputs = ActionsTestUtil.baseArtifactNames(deployJarAction.getInputs()); assertThat(inputs) .containsAtLeast( "libsublib.jar_desugared.jar", "liblib.jar_desugared.jar", "libbin.jar_desugared.jar", "bin_resources.jar_desugared.jar"); assertThat(inputs) .containsNoneOf("lib_resources.jar_desugared.jar", "sublib_resources.jar_desugared.jar"); } @Test public void testLocalResourcesUseRClassGenerator() throws Exception { scratch.file("java/r/android/BUILD", "android_library(name = 'lib',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res2/**']),", " )", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res/**']),", " deps = [':lib'],", " )"); scratch.file("java/r/android/res2/values/strings.xml", "<resources><string name = 'lib_string'>Libs!</string></resources>"); scratch.file("java/r/android/res/values/strings.xml", "<resources><string name = 'hello'>Hello Android!</string></resources>"); Artifact jar = getResourceClassJar(getConfiguredTargetAndData("//java/r/android:r")); assertThat(getGeneratingAction(jar).getMnemonic()).isEqualTo("RClassGenerator"); assertThat(getGeneratingSpawnActionArgs(jar)) .containsAtLeast("--primaryRTxt", "--primaryManifest", "--library", "--classJarOutput"); } @Test public void testLocalResourcesUseRClassGeneratorNoLibraries() throws Exception { scratch.file("java/r/android/BUILD", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res/**']),", " )"); scratch.file("java/r/android/res/values/strings.xml", "<resources><string name = 'hello'>Hello Android!</string></resources>"); Artifact jar = getResourceClassJar(getConfiguredTargetAndData("//java/r/android:r")); assertThat(getGeneratingAction(jar).getMnemonic()).isEqualTo("RClassGenerator"); List<String> args = getGeneratingSpawnActionArgs(jar); assertThat(args).containsAtLeast("--primaryRTxt", "--primaryManifest", "--classJarOutput"); assertThat(args).doesNotContain("--libraries"); } @Test public void testUseRClassGeneratorCustomPackage() throws Exception { scratch.file("java/r/android/BUILD", "android_library(name = 'lib',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res2/**']),", " custom_package = 'com.lib.custom',", " )", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res/**']),", " custom_package = 'com.binary.custom',", " deps = [':lib'],", " )"); scratch.file("java/r/android/res2/values/strings.xml", "<resources><string name = 'lib_string'>Libs!</string></resources>"); scratch.file("java/r/android/res/values/strings.xml", "<resources><string name = 'hello'>Hello Android!</string></resources>"); ConfiguredTargetAndData binary = getConfiguredTargetAndData("//java/r/android:r"); Artifact jar = getResourceClassJar(binary); assertThat(getGeneratingAction(jar).getMnemonic()).isEqualTo("RClassGenerator"); List<String> args = getGeneratingSpawnActionArgs(jar); assertThat(args) .containsAtLeast( "--primaryRTxt", "--primaryManifest", "--library", "--classJarOutput", "--packageForR", "com.binary.custom"); } @Test public void testUseRClassGeneratorMultipleDeps() throws Exception { scratch.file( "java/r/android/BUILD", "android_library(name = 'lib1',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res1/**']),", " )", "android_library(name = 'lib2',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res2/**']),", " )", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res/**']),", " deps = [':lib1', ':lib2'],", " )"); ConfiguredTargetAndData binary = getConfiguredTargetAndData("//java/r/android:r"); Artifact jar = getResourceClassJar(binary); assertThat(getGeneratingAction(jar).getMnemonic()).isEqualTo("RClassGenerator"); List<String> args = getGeneratingSpawnActionArgs(jar); AndroidResourcesInfo resourcesInfo = binary.getConfiguredTarget().get(AndroidResourcesInfo.PROVIDER); assertThat(resourcesInfo.getTransitiveAndroidResources()).hasSize(2); ValidatedAndroidResources firstDep = resourcesInfo.getTransitiveAndroidResources().toList().get(0); ValidatedAndroidResources secondDep = resourcesInfo.getTransitiveAndroidResources().toList().get(1); assertThat(args) .containsAtLeast( "--primaryRTxt", "--primaryManifest", "--library", firstDep.getRTxt().getExecPathString() + "," + firstDep.getManifest().getExecPathString(), "--library", secondDep.getRTxt().getExecPathString() + "," + secondDep.getManifest().getExecPathString(), "--classJarOutput") .inOrder(); } @Test public void testNoCrunchBinaryOnly() throws Exception { scratch.file("java/r/android/BUILD", "android_binary(name = 'r',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/drawable-hdpi-v4/foo.png',", " 'res/drawable-hdpi-v4/bar.9.png'],", " crunch_png = 0,", " )"); ConfiguredTarget binary = getConfiguredTarget("//java/r/android:r"); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(binary)); assertThat(args).contains("--useAaptCruncher=no"); } @Test public void testDoCrunch() throws Exception { scratch.file("java/r/android/BUILD", "android_binary(name = 'r',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/drawable-hdpi-v4/foo.png',", " 'res/drawable-hdpi-v4/bar.9.png'],", " crunch_png = 1,", " )"); ConfiguredTarget binary = getConfiguredTarget("//java/r/android:r"); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(binary)); assertThat(args).doesNotContain("--useAaptCruncher=no"); } @Test public void testDoCrunchDefault() throws Exception { scratch.file("java/r/android/BUILD", "android_binary(name = 'r',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/drawable-hdpi-v4/foo.png',", " 'res/drawable-hdpi-v4/bar.9.png'],", " )"); ConfiguredTarget binary = getConfiguredTarget("//java/r/android:r"); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(binary)); assertThat(args).doesNotContain("--useAaptCruncher=no"); } @Test public void testNoCrunchWithAndroidLibraryNoBinaryResources() throws Exception { scratch.file("java/r/android/BUILD", "android_library(name = 'resources',", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/values/strings.xml',", " 'res/drawable-hdpi-v4/foo.png',", " 'res/drawable-hdpi-v4/bar.9.png'],", " )", "android_binary(name = 'r',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " deps = [':resources'],", " crunch_png = 0,", " )"); ConfiguredTarget binary = getConfiguredTarget("//java/r/android:r"); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(binary)); assertThat(args).contains("--useAaptCruncher=no"); } @Test public void testNoCrunchWithMultidexNative() throws Exception { scratch.file("java/r/android/BUILD", "android_library(name = 'resources',", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/values/strings.xml',", " 'res/drawable-hdpi-v4/foo.png',", " 'res/drawable-hdpi-v4/bar.9.png'],", " )", "android_binary(name = 'r',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " deps = [':resources'],", " multidex = 'native',", " crunch_png = 0,", " )"); ConfiguredTarget binary = getConfiguredTarget("//java/r/android:r"); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(binary)); assertThat(args).contains("--useAaptCruncher=no"); } @Test public void testZipaligned() throws Exception { ConfiguredTarget binary = getConfiguredTarget("//java/android:app"); Artifact a = ActionsTestUtil.getFirstArtifactEndingWith( actionsTestUtil().artifactClosureOf(getFilesToBuild(binary)), "zipaligned_app.apk"); SpawnAction action = getGeneratingSpawnAction(a); assertThat(action.getMnemonic()).isEqualTo("AndroidZipAlign"); List<String> arguments = getGeneratingSpawnActionArgs(a); assertThat(arguments).contains("-p"); assertThat(arguments).contains("4"); Artifact zipAlignTool = getFirstArtifactEndingWith(action.getInputs(), "/zipalign"); assertThat(arguments).contains(zipAlignTool.getExecPathString()); Artifact unsignedApk = getFirstArtifactEndingWith(action.getInputs(), "/app_unsigned.apk"); assertThat(arguments).contains(unsignedApk.getExecPathString()); Artifact zipalignedApk = getFirstArtifactEndingWith(action.getOutputs(), "/zipaligned_app.apk"); assertThat(arguments).contains(zipalignedApk.getExecPathString()); } @Test public void testDeployInfo() throws Exception { ConfiguredTarget binary = getConfiguredTarget("//java/android:app"); NestedSet<Artifact> outputGroup = getOutputGroup(binary, "android_deploy_info"); Artifact deployInfoArtifact = ActionsTestUtil .getFirstArtifactEndingWith(outputGroup, "/deploy_info.deployinfo.pb"); assertThat(deployInfoArtifact).isNotNull(); AndroidDeployInfo deployInfo = getAndroidDeployInfo(deployInfoArtifact); assertThat(deployInfo).isNotNull(); assertThat(deployInfo.getMergedManifest().getExecRootPath()).endsWith( "/AndroidManifest.xml"); assertThat(deployInfo.getAdditionalMergedManifestsList()).isEmpty(); assertThat(deployInfo.getApksToDeploy(0).getExecRootPath()).endsWith("/app.apk"); } /** * Internal helper method: checks that dex sharding input and output is correct for * different combinations of multidex mode and build with and without proguard. */ private void internalTestDexShardStructure(MultidexMode multidexMode, boolean proguard, String nonProguardSuffix) throws Exception { ConfiguredTarget target = getConfiguredTarget("//java/a:a"); assertNoEvents(); Action shardAction = getGeneratingAction(getBinArtifact("_dx/a/shard1.jar", target)); // Verify command line arguments List<String> arguments = ((SpawnAction) shardAction).getRemainingArguments(); List<String> expectedArguments = new ArrayList<>(); Set<Artifact> artifacts = actionsTestUtil().artifactClosureOf(getFilesToBuild(target)); Artifact shard1 = getFirstArtifactEndingWith(artifacts, "shard1.jar"); Artifact shard2 = getFirstArtifactEndingWith(artifacts, "shard2.jar"); Artifact resourceJar = getFirstArtifactEndingWith(artifacts, "/java_resources.jar"); expectedArguments.add("--output_jar"); expectedArguments.add(shard1.getExecPathString()); expectedArguments.add("--output_jar"); expectedArguments.add(shard2.getExecPathString()); expectedArguments.add("--output_resources"); expectedArguments.add(resourceJar.getExecPathString()); if (multidexMode == MultidexMode.LEGACY) { Artifact mainDexList = getFirstArtifactEndingWith(artifacts, "main_dex_list.txt"); expectedArguments.add("--main_dex_filter"); expectedArguments.add(mainDexList.getExecPathString()); } if (!proguard) { expectedArguments.add("--input_jar"); expectedArguments.add( getFirstArtifactEndingWith(artifacts, "a_resources.jar" + nonProguardSuffix) .getExecPathString()); } Artifact inputJar; if (proguard) { inputJar = getFirstArtifactEndingWith(artifacts, "a_proguard.jar"); } else { inputJar = getFirstArtifactEndingWith(artifacts, "liba.jar" + nonProguardSuffix); } expectedArguments.add("--input_jar"); expectedArguments.add(inputJar.getExecPathString()); assertThat(arguments).containsExactlyElementsIn(expectedArguments).inOrder(); // Verify input and output artifacts List<String> shardOutputs = ActionsTestUtil.baseArtifactNames(shardAction.getOutputs()); List<String> shardInputs = ActionsTestUtil.baseArtifactNames(shardAction.getInputs()); assertThat(shardOutputs) .containsExactly("shard1.jar", "shard2.jar", "java_resources.jar"); if (multidexMode == MultidexMode.LEGACY) { assertThat(shardInputs).contains("main_dex_list.txt"); } else { assertThat(shardInputs).doesNotContain("main_dex_list.txt"); } if (proguard) { assertThat(shardInputs).contains("a_proguard.jar"); assertThat(shardInputs).doesNotContain("liba.jar" + nonProguardSuffix); } else { assertThat(shardInputs).contains("liba.jar" + nonProguardSuffix); assertThat(shardInputs).doesNotContain("a_proguard.jar"); } assertThat(shardInputs).doesNotContain("a_deploy.jar"); // Verify that dex compilation is followed by the correct merge operation Action apkAction = getGeneratingAction(getFirstArtifactEndingWith( actionsTestUtil().artifactClosureOf(getFilesToBuild(target)), "compressed_a_unsigned.apk")); Action mergeAction = getGeneratingAction(getFirstArtifactEndingWith( apkAction.getInputs(), "classes.dex.zip")); Iterable<Artifact> dexShards = Iterables.filter( mergeAction.getInputs(), ActionsTestUtil.getArtifactSuffixMatcher(".dex.zip")); assertThat(ActionsTestUtil.baseArtifactNames(dexShards)) .containsExactly("shard1.dex.zip", "shard2.dex.zip"); } @Test public void testDexShardingNeedsMultidex() throws Exception { scratch.file("java/a/BUILD", "android_binary(", " name='a',", " srcs=['A.java'],", " dex_shards=2,", " manifest='AndroidManifest.xml')"); reporter.removeHandler(failFastHandler); getConfiguredTarget("//java/a:a"); assertContainsEvent(".dex sharding is only available in multidex mode"); } @Test public void testDexShardingDoesNotWorkWithManualMultidex() throws Exception { scratch.file("java/a/BUILD", "android_binary(", " name='a',", " srcs=['A.java'],", " dex_shards=2,", " multidex='manual_main_dex',", " main_dex_list='main_dex_list.txt',", " manifest='AndroidManifest.xml')"); reporter.removeHandler(failFastHandler); getConfiguredTarget("//java/a:a"); assertContainsEvent(".dex sharding is not available in manual multidex mode"); } @Test public void testDexShardingLegacyStructure() throws Exception { useConfiguration("--noincremental_dexing"); scratch.file("java/a/BUILD", "android_binary(", " name='a',", " srcs=['A.java'],", " dex_shards=2,", " multidex='legacy',", " manifest='AndroidManifest.xml')"); internalTestDexShardStructure(MultidexMode.LEGACY, false, "_desugared.jar"); } @Test public void testDexShardingNativeStructure_withNoDesugaring() throws Exception { useConfiguration("--noexperimental_desugar_for_android", "--noincremental_dexing"); scratch.file("java/a/BUILD", "android_binary(", " name='a',", " srcs=['A.java'],", " dex_shards=2,", " multidex='native',", " manifest='AndroidManifest.xml')"); internalTestDexShardStructure(MultidexMode.NATIVE, false, ""); } @Test public void testDexShardingNativeStructure() throws Exception { useConfiguration("--noincremental_dexing"); scratch.file("java/a/BUILD", "android_binary(", " name='a',", " srcs=['A.java'],", " dex_shards=2,", " multidex='native',", " manifest='AndroidManifest.xml')"); internalTestDexShardStructure(MultidexMode.NATIVE, false, "_desugared.jar"); } @Test public void testDexShardingLegacyAndProguardStructure_withNoDesugaring() throws Exception { useConfiguration("--noexperimental_desugar_for_android"); scratch.file("java/a/BUILD", "android_binary(", " name='a',", " srcs=['A.java'],", " dex_shards=2,", " multidex='legacy',", " manifest='AndroidManifest.xml',", " proguard_specs=['proguard.cfg'])"); internalTestDexShardStructure(MultidexMode.LEGACY, true, ""); } @Test public void testDexShardingLegacyAndProguardStructure() throws Exception { scratch.file("java/a/BUILD", "android_binary(", " name='a',", " srcs=['A.java'],", " dex_shards=2,", " multidex='legacy',", " manifest='AndroidManifest.xml',", " proguard_specs=['proguard.cfg'])"); internalTestDexShardStructure(MultidexMode.LEGACY, true, "_desugared.jar"); } @Test public void testDexShardingNativeAndProguardStructure() throws Exception { scratch.file("java/a/BUILD", "android_binary(", " name='a',", " srcs=['A.java'],", " dex_shards=2,", " multidex='native',", " manifest='AndroidManifest.xml',", " proguard_specs=['proguard.cfg'])"); internalTestDexShardStructure(MultidexMode.NATIVE, true, ""); } @Test public void testIncrementalApkAndProguardBuildStructure() throws Exception { scratch.file("java/a/BUILD", "android_binary(", " name='a',", " srcs=['A.java'],", " dex_shards=2,", " multidex='native',", " manifest='AndroidManifest.xml',", " proguard_specs=['proguard.cfg'])"); ConfiguredTarget target = getConfiguredTarget("//java/a:a"); Action shardAction = getGeneratingAction(getBinArtifact("_dx/a/shard1.jar", target)); List<String> shardOutputs = ActionsTestUtil.baseArtifactNames(shardAction.getOutputs()); assertThat(shardOutputs).contains("java_resources.jar"); assertThat(shardOutputs).doesNotContain("a_deploy.jar"); } @Test public void testManualMainDexBuildStructure() throws Exception { checkError("java/foo", "maindex_nomultidex", "Both \"main_dex_list\" and \"multidex='manual_main_dex'\" must be specified", "android_binary(", " name = 'maindex_nomultidex',", " srcs = ['a.java'],", " manifest = 'AndroidManifest.xml',", " multidex = 'manual_main_dex')"); } @Test public void testMainDexListLegacyMultidex() throws Exception { checkError("java/foo", "maindex_nomultidex", "Both \"main_dex_list\" and \"multidex='manual_main_dex'\" must be specified", "android_binary(", " name = 'maindex_nomultidex',", " srcs = ['a.java'],", " manifest = 'AndroidManifest.xml',", " multidex = 'legacy',", " main_dex_list = 'main_dex_list.txt')"); } @Test public void testMainDexListNativeMultidex() throws Exception { checkError("java/foo", "maindex_nomultidex", "Both \"main_dex_list\" and \"multidex='manual_main_dex'\" must be specified", "android_binary(", " name = 'maindex_nomultidex',", " srcs = ['a.java'],", " manifest = 'AndroidManifest.xml',", " multidex = 'native',", " main_dex_list = 'main_dex_list.txt')"); } @Test public void testMainDexListNoMultidex() throws Exception { checkError("java/foo", "maindex_nomultidex", "Both \"main_dex_list\" and \"multidex='manual_main_dex'\" must be specified", "android_binary(", " name = 'maindex_nomultidex',", " srcs = ['a.java'],", " manifest = 'AndroidManifest.xml',", " main_dex_list = 'main_dex_list.txt')"); } @Test public void testMainDexListWithAndroidSdk() throws Exception { scratch.file( "sdk/BUILD", "android_sdk(", " name = 'sdk',", " aapt = 'aapt',", " adb = 'adb',", " aidl = 'aidl',", " android_jar = 'android.jar',", " apksigner = 'apksigner',", " dx = 'dx',", " framework_aidl = 'framework_aidl',", " main_dex_classes = 'main_dex_classes',", " main_dex_list_creator = 'main_dex_list_creator',", " proguard = 'proguard',", " shrinked_android_jar = 'shrinked_android_jar',", " zipalign = 'zipalign',", " tags = ['__ANDROID_RULES_MIGRATION__'])"); scratch.file("java/a/BUILD", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " multidex = 'legacy',", " main_dex_list_opts = ['--hello', '--world'])"); useConfiguration("--android_sdk=//sdk:sdk"); ConfiguredTarget a = getConfiguredTarget("//java/a:a"); Artifact mainDexList = ActionsTestUtil.getFirstArtifactEndingWith( actionsTestUtil().artifactClosureOf(getFilesToBuild(a)), "main_dex_list.txt"); List<String> args = getGeneratingSpawnActionArgs(mainDexList); assertThat(args).containsAtLeast("--hello", "--world"); } @Test public void testMainDexAaptGenerationSupported() throws Exception { useConfiguration("--android_sdk=//sdk:sdk", "--noincremental_dexing"); scratch.file( "sdk/BUILD", "android_sdk(", " name = 'sdk',", " build_tools_version = '24.0.0',", " aapt = 'aapt',", " adb = 'adb',", " aidl = 'aidl',", " android_jar = 'android.jar',", " apksigner = 'apksigner',", " dx = 'dx',", " framework_aidl = 'framework_aidl',", " main_dex_classes = 'main_dex_classes',", " main_dex_list_creator = 'main_dex_list_creator',", " proguard = 'proguard',", " shrinked_android_jar = 'shrinked_android_jar',", " zipalign = 'zipalign',", " tags = ['__ANDROID_RULES_MIGRATION__'])"); scratch.file("java/a/BUILD", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " multidex = 'legacy')"); ConfiguredTarget a = getConfiguredTarget("//java/a:a"); Artifact intermediateJar = artifactByPath(ImmutableList.of(getCompressedUnsignedApk(a)), ".apk", ".dex.zip", ".dex.zip", "main_dex_list.txt", "_intermediate.jar"); List<String> args = getGeneratingSpawnActionArgs(intermediateJar); assertContainsSublist( args, ImmutableList.of( "-include", targetConfig.getBinFragment() + "/java/a/proguard/a/main_dex_a_proguard.cfg")); } @Test public void testMainDexGenerationWithoutProguardMap() throws Exception { useConfiguration("--noincremental_dexing"); scratchConfiguredTarget("java/foo", "abin", "android_binary(", " name = 'abin',", " srcs = ['a.java'],", " proguard_specs = [],", " manifest = 'AndroidManifest.xml',", " multidex = 'legacy',)"); ConfiguredTarget a = getConfiguredTarget("//java/foo:abin"); Artifact intermediateJar = artifactByPath(ImmutableList.of(getCompressedUnsignedApk(a)), ".apk", ".dex.zip", ".dex.zip", "main_dex_list.txt", "_intermediate.jar"); List<String> args = getGeneratingSpawnActionArgs(intermediateJar); MoreAsserts.assertDoesNotContainSublist( args, "-previousobfuscationmap"); } // regression test for b/14288948 @Test public void testEmptyListAsProguardSpec() throws Exception { scratch.file( "java/foo/BUILD", "android_binary(", " name = 'abin',", " srcs = ['a.java'],", " proguard_specs = [],", " manifest = 'AndroidManifest.xml')"); Rule rule = getTarget("//java/foo:abin").getAssociatedRule(); assertNoEvents(); ImmutableList<String> implicitOutputFilenames = rule.getOutputFiles().stream().map(FileTarget::getName).collect(toImmutableList()); assertThat(implicitOutputFilenames).doesNotContain("abin_proguard.jar"); } @Test public void testConfigurableProguardSpecsEmptyList() throws Exception { scratch.file( "java/foo/BUILD", "android_binary(", " name = 'abin',", " srcs = ['a.java'],", " proguard_specs = select({", " '" + BuildType.Selector.DEFAULT_CONDITION_KEY + "': [],", " }),", " manifest = 'AndroidManifest.xml')"); Rule rule = getTarget("//java/foo:abin").getAssociatedRule(); assertNoEvents(); ImmutableList<String> implicitOutputFilenames = rule.getOutputFiles().stream().map(FileTarget::getName).collect(toImmutableList()); assertThat(implicitOutputFilenames).contains("abin_proguard.jar"); } @Test public void testConfigurableProguardSpecsEmptyListWithMapping() throws Exception { scratchConfiguredTarget("java/foo", "abin", "android_binary(", " name = 'abin',", " srcs = ['a.java'],", " proguard_specs = select({", " '" + BuildType.Selector.DEFAULT_CONDITION_KEY + "': [],", " }),", " proguard_generate_mapping = 1,", " manifest = 'AndroidManifest.xml')"); assertNoEvents(); } @Test public void testResourcesWithConfigurationQualifier_LocalResources() throws Exception { scratch.file("java/android/resources/BUILD", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = glob(['res/**']),", " )"); scratch.file("java/android/resources/res/values-en/strings.xml", "<resources><string name = 'hello'>Hello Android!</string></resources>"); scratch.file("java/android/resources/res/values/strings.xml", "<resources><string name = 'hello'>Hello Android!</string></resources>"); ConfiguredTarget resource = getConfiguredTarget("//java/android/resources:r"); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(resource)); assertPrimaryResourceDirs(ImmutableList.of("java/android/resources/res"), args); } @Test public void testResourcesInOtherPackage_exported_LocalResources() throws Exception { scratch.file("java/android/resources/BUILD", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = ['//java/resources/other:res/values/strings.xml'],", " )"); scratch.file("java/resources/other/BUILD", "exports_files(['res/values/strings.xml'])"); ConfiguredTarget resource = getConfiguredTarget("//java/android/resources:r"); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(resource)); assertPrimaryResourceDirs(ImmutableList.of("java/resources/other/res"), args); assertNoEvents(); } @Test public void testResourcesInOtherPackage_filegroup_LocalResources() throws Exception { scratch.file("java/android/resources/BUILD", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = ['//java/other/resources:fg'],", " )"); scratch.file("java/other/resources/BUILD", "filegroup(name = 'fg',", " srcs = ['res/values/strings.xml'],", ")"); ConfiguredTarget resource = getConfiguredTarget("//java/android/resources:r"); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(resource)); assertPrimaryResourceDirs(ImmutableList.of("java/other/resources/res"), args); assertNoEvents(); } @Test public void testResourcesInOtherPackage_filegroupWithExternalSources_LocalResources() throws Exception { scratch.file("java/android/resources/BUILD", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = [':fg'],", " )", "filegroup(name = 'fg',", " srcs = ['//java/other/resources:res/values/strings.xml'])"); scratch.file("java/other/resources/BUILD", "exports_files(['res/values/strings.xml'])"); ConfiguredTarget resource = getConfiguredTarget("//java/android/resources:r"); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(resource)); assertPrimaryResourceDirs(ImmutableList.of("java/other/resources/res"), args); assertNoEvents(); } @Test public void testMultipleDependentResourceDirectories_LocalResources() throws Exception { scratch.file("java/android/resources/d1/BUILD", "android_library(name = 'd1',", " manifest = 'AndroidManifest.xml',", " resource_files = ['d1-res/values/strings.xml'],", " )"); scratch.file("java/android/resources/d2/BUILD", "android_library(name = 'd2',", " manifest = 'AndroidManifest.xml',", " resource_files = ['d2-res/values/strings.xml'],", " )"); scratch.file("java/android/resources/BUILD", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = ['bin-res/values/strings.xml'],", " deps = [", " '//java/android/resources/d1:d1','//java/android/resources/d2:d2'", " ])"); ConfiguredTarget resource = getConfiguredTarget("//java/android/resources:r"); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(resource)); assertPrimaryResourceDirs(ImmutableList.of("java/android/resources/bin-res"), args); assertThat(getDirectDependentResourceDirs(args)) .containsAtLeast("java/android/resources/d1/d1-res", "java/android/resources/d2/d2-res"); assertNoEvents(); } // Regression test for b/11924769 @Test public void testResourcesInOtherPackage_doubleFilegroup_LocalResources() throws Exception { scratch.file("java/android/resources/BUILD", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = [':fg'],", " )", "filegroup(name = 'fg',", " srcs = ['//java/other/resources:fg'])"); scratch.file("java/other/resources/BUILD", "filegroup(name = 'fg',", " srcs = ['res/values/strings.xml'],", ")"); ConfiguredTarget resource = getConfiguredTarget("//java/android/resources:r"); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(resource)); assertPrimaryResourceDirs(ImmutableList.of("java/other/resources/res"), args); assertNoEvents(); } @Test public void testManifestMissingFails_LocalResources() throws Exception { checkError("java/android/resources", "r", "manifest attribute of android_library rule //java/android/resources:r: manifest is " + "required when resource_files or assets are defined.", "filegroup(name = 'b')", "android_library(name = 'r',", " resource_files = [':b'],", " )"); } @Test public void testResourcesDoesNotMatchDirectoryLayout_BadFile_LocalResources() throws Exception { checkError("java/android/resources", "r", "'java/android/resources/res/somefile.xml' is not in the expected resource directory " + "structure of <resource directory>/{" + Joiner.on(',').join(AndroidResources.RESOURCE_DIRECTORY_TYPES) + "}", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/somefile.xml', 'r/t/f/m/raw/fold']", " )"); } @Test public void testResourcesDoesNotMatchDirectoryLayout_BadDirectory_LocalResources() throws Exception { checkError("java/android/resources", "r", "'java/android/resources/res/other/somefile.xml' is not in the expected resource directory " + "structure of <resource directory>/{" + Joiner.on(',').join(AndroidResources.RESOURCE_DIRECTORY_TYPES) + "}", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/other/somefile.xml', 'r/t/f/m/raw/fold']", " )"); } @Test public void testResourcesNotUnderCommonDirectoryFails_LocalResources() throws Exception { checkError("java/android/resources", "r", "'java/android/resources/r/t/f/m/raw/fold' (generated by '//java/android/resources:r/t/f/m/" + "raw/fold') is not in the same directory 'res' " + "(derived from java/android/resources/res/raw/speed). " + "All resources must share a common directory", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/raw/speed', 'r/t/f/m/raw/fold']", " )"); } @Test public void testAssetsAndNoAssetsDirFails_LocalResources() throws Exception { scratch.file("java/android/resources/assets/values/strings.xml", "<resources><string name = 'hello'>Hello Android!</string></resources>"); checkError("java/android/resources", "r", "'assets' and 'assets_dir' should be either both empty or both non-empty", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " assets = glob(['assets/**']),", " )"); } @Test public void testAssetsDirAndNoAssetsFails_LocalResources() throws Exception { checkError("java/cpp/android", "r", "'assets' and 'assets_dir' should be either both empty or both non-empty", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " assets_dir = 'assets',", " )"); } @Test public void testAssetsNotUnderAssetsDirFails_LocalResources() throws Exception { checkError("java/android/resources", "r", "'java/android/resources/r/t/f/m' (generated by '//java/android/resources:r/t/f/m') " + "is not beneath 'assets'", "android_binary(name = 'r',", " manifest = 'AndroidManifest.xml',", " assets_dir = 'assets',", " assets = ['assets/valuable', 'r/t/f/m']", " )"); } @Test public void testFileLocation_LocalResources() throws Exception { scratch.file("java/android/resources/BUILD", "android_binary(name = 'r',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/values/strings.xml'],", " )"); ConfiguredTarget r = getConfiguredTarget("//java/android/resources:r"); assertThat(getFirstArtifactEndingWith(getFilesToBuild(r), ".apk").getRoot()) .isEqualTo(getTargetConfiguration().getBinDirectory(RepositoryName.MAIN)); } @Test public void testCustomPackage_LocalResources() throws Exception { scratch.file("a/r/BUILD", "android_binary(name = 'r',", " srcs = ['Foo.java'],", " custom_package = 'com.google.android.bar',", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/values/strings.xml'],", " )"); ConfiguredTarget r = getConfiguredTarget("//a/r:r"); assertNoEvents(); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(r)); assertContainsSublist(args, ImmutableList.of("--packageForR", "com.google.android.bar")); } @Test public void testCustomJavacopts() throws Exception { scratch.file("java/foo/A.java", "foo"); scratch.file("java/foo/BUILD", "android_binary(name = 'a', manifest = 'AndroidManifest.xml', ", " srcs = ['A.java'], javacopts = ['-g:lines,source'])"); Artifact deployJar = getFileConfiguredTarget("//java/foo:a_deploy.jar").getArtifact(); Action deployAction = getGeneratingAction(deployJar); JavaCompileAction javacAction = (JavaCompileAction) actionsTestUtil() .getActionForArtifactEndingWith( actionsTestUtil().artifactClosureOf(deployAction.getInputs()), "liba.jar"); assertThat(getJavacArguments(javacAction)).contains("-g:lines,source"); } @Test public void testFixDepsToolFlag() throws Exception { useConfiguration("--experimental_fix_deps_tool=autofixer"); scratch.file("java/foo/A.java", "foo"); scratch.file( "java/foo/BUILD", "android_binary(name = 'a', manifest = 'AndroidManifest.xml', ", " srcs = ['A.java'])"); Iterable<String> commandLine = getJavacArguments( ((JavaCompileAction) actionsTestUtil() .getActionForArtifactEndingWith( actionsTestUtil() .artifactClosureOf( getGeneratingAction( getFileConfiguredTarget("//java/foo:a_deploy.jar") .getArtifact()) .getInputs()), "liba.jar"))); assertThat(commandLine).containsAtLeast("--experimental_fix_deps_tool", "autofixer").inOrder(); } @Test public void testFixDepsToolFlagEmpty() throws Exception { scratch.file("java/foo/A.java", "foo"); scratch.file( "java/foo/BUILD", "android_binary(name = 'a', manifest = 'AndroidManifest.xml', ", " srcs = ['A.java'])"); Iterable<String> commandLine = getJavacArguments( ((JavaCompileAction) actionsTestUtil() .getActionForArtifactEndingWith( actionsTestUtil() .artifactClosureOf( getGeneratingAction( getFileConfiguredTarget("//java/foo:a_deploy.jar") .getArtifact()) .getInputs()), "liba.jar"))); assertThat(commandLine).containsAtLeast("--experimental_fix_deps_tool", "add_dep").inOrder(); } @Test public void testAndroidBinaryExportsJavaCompilationArgsProvider() throws Exception { scratch.file("java/foo/A.java", "foo"); scratch.file("java/foo/BUILD", "android_binary(name = 'a', manifest = 'AndroidManifest.xml', ", " srcs = ['A.java'], javacopts = ['-g:lines,source'])"); final JavaCompilationArgsProvider provider = JavaInfo .getProvider(JavaCompilationArgsProvider.class, getConfiguredTarget("//java/foo:a")); assertThat(provider).isNotNull(); } @Test public void testNoApplicationId_LocalResources() throws Exception { scratch.file("java/a/r/BUILD", "android_binary(name = 'r',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/values/strings.xml'],", " )"); ConfiguredTarget r = getConfiguredTarget("//java/a/r:r"); assertNoEvents(); List<String> args = getGeneratingSpawnActionArgs(getResourceApk(r)); Truth.assertThat(args).doesNotContain("--applicationId"); } @Test public void testDisallowPrecompiledJars() throws Exception { checkError("java/precompiled", "binary", // messages: "does not produce any android_binary srcs files (expected .java or .srcjar)", // build file: "android_binary(name = 'binary',", " manifest='AndroidManifest.xml',", " srcs = [':jar'])", "filegroup(name = 'jar',", " srcs = ['lib.jar'])"); } @Test public void testDesugarJava8Libs_noProguard() throws Exception { useConfiguration("--experimental_desugar_java8_libs"); scratch.file( "java/com/google/android/BUILD", "android_binary(", " name = 'foo',", " srcs = ['foo.java'],", " manifest = 'AndroidManifest.xml',", " multidex = 'native',", ")"); ConfiguredTarget top = getConfiguredTarget("//java/com/google/android:foo"); Artifact artifact = getBinArtifact("_dx/foo/_final_classes.dex.zip", top); assertWithMessage("_final_classes.dex.zip").that(artifact).isNotNull(); Action generatingAction = getGeneratingAction(artifact); assertThat(ActionsTestUtil.baseArtifactNames(generatingAction.getInputs())) .containsAtLeast("classes.dex.zip", /*canned*/ "java8_legacy.dex.zip"); } @Test public void testDesugarJava8Libs_withProguard() throws Exception { useConfiguration("--experimental_desugar_java8_libs"); scratch.file( "java/com/google/android/BUILD", "android_binary(", " name = 'foo',", " srcs = ['foo.java'],", " manifest = 'AndroidManifest.xml',", " multidex = 'native',", " proguard_specs = ['foo.cfg'],", ")"); ConfiguredTarget top = getConfiguredTarget("//java/com/google/android:foo"); Artifact artifact = getBinArtifact("_dx/foo/_final_classes.dex.zip", top); assertWithMessage("_final_classes.dex.zip").that(artifact).isNotNull(); Action generatingAction = getGeneratingAction(artifact); assertThat(ActionsTestUtil.baseArtifactNames(generatingAction.getInputs())) .containsAtLeast("classes.dex.zip", /*built*/ "_java8_legacy.dex.zip"); } @Test public void testDesugarJava8Libs_noMultidexError() throws Exception { useConfiguration("--experimental_desugar_java8_libs"); checkError(/*packageName=*/ "java/com/google/android", /*ruleName=*/ "foo", /*expectedErrorMessage=*/ "multidex", "android_binary(", " name = 'foo',", " srcs = ['foo.java'],", " manifest = 'AndroidManifest.xml',", ")"); } @Test public void testApplyProguardMapping() throws Exception { scratch.file( "java/com/google/android/BUILD", "android_binary(", " name = 'foo',", " srcs = ['foo.java'],", " proguard_apply_mapping = 'proguard.map',", " proguard_specs = ['foo.pro'],", " manifest = 'AndroidManifest.xml',", ")"); ConfiguredTarget ct = getConfiguredTarget("//java/com/google/android:foo"); Artifact artifact = artifactByPath(getFilesToBuild(ct), "_proguard.jar"); Action generatingAction = getGeneratingAction(artifact); assertThat(Artifact.toExecPaths(generatingAction.getInputs())) .contains("java/com/google/android/proguard.map"); // Cannot use assertThat().containsAllOf().inOrder() as that does not assert that the elements // are consecutive. MoreAsserts.assertContainsSublist(getGeneratingSpawnActionArgs(artifact), "-applymapping", "java/com/google/android/proguard.map"); } @Test public void testApplyProguardMappingWithNoSpec() throws Exception { checkError( "java/com/google/android", "foo", // messages: "'proguard_apply_mapping' can only be used when 'proguard_specs' is also set", // build file: "android_binary(", " name = 'foo',", " srcs = ['foo.java'],", " proguard_apply_mapping = 'proguard.map',", " manifest = 'AndroidManifest.xml',", ")"); } @Test public void testApplyProguardDictionary() throws Exception { scratch.file( "java/com/google/android/BUILD", "android_binary(", " name = 'foo',", " srcs = ['foo.java'],", " proguard_apply_dictionary = 'dictionary.txt',", " proguard_specs = ['foo.pro'],", " manifest = 'AndroidManifest.xml',", ")"); ConfiguredTarget ct = getConfiguredTarget("//java/com/google/android:foo"); Artifact artifact = artifactByPath(getFilesToBuild(ct), "_proguard.jar"); Action generatingAction = getGeneratingAction(artifact); assertThat(Artifact.toExecPaths(generatingAction.getInputs())) .contains("java/com/google/android/dictionary.txt"); // Cannot use assertThat().containsAllOf().inOrder() as that does not assert that the elements // are consecutive. MoreAsserts.assertContainsSublist(getGeneratingSpawnActionArgs(artifact), "-obfuscationdictionary", "java/com/google/android/dictionary.txt"); MoreAsserts.assertContainsSublist(getGeneratingSpawnActionArgs(artifact), "-classobfuscationdictionary", "java/com/google/android/dictionary.txt"); MoreAsserts.assertContainsSublist(getGeneratingSpawnActionArgs(artifact), "-packageobfuscationdictionary", "java/com/google/android/dictionary.txt"); } @Test public void testApplyProguardDictionaryWithNoSpec() throws Exception { checkError( "java/com/google/android", "foo", // messages: "'proguard_apply_dictionary' can only be used when 'proguard_specs' is also set", // build file: "android_binary(", " name = 'foo',", " srcs = ['foo.java'],", " proguard_apply_dictionary = 'dictionary.txt',", " manifest = 'AndroidManifest.xml',", ")"); } @Test public void testFeatureFlagsAttributeSetsSelectInDependency() throws Exception { useConfiguration( "--experimental_dynamic_configs=notrim", "--enforce_transitive_configs_for_config_feature_flag"); scratch.file( "java/com/foo/BUILD", "config_feature_flag(", " name = 'flag1',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "config_setting(", " name = 'flag1@on',", " flag_values = {':flag1': 'on'},", " transitive_configs = [':flag1'],", ")", "config_feature_flag(", " name = 'flag2',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "config_setting(", " name = 'flag2@on',", " flag_values = {':flag2': 'on'},", " transitive_configs = [':flag2'],", ")", "android_library(", " name = 'lib',", " srcs = select({", " ':flag1@on': ['Flag1On.java'],", " '//conditions:default': ['Flag1Off.java'],", " }) + select({", " ':flag2@on': ['Flag2On.java'],", " '//conditions:default': ['Flag2Off.java'],", " }),", " transitive_configs = [':flag1', ':flag2'],", ")", "android_binary(", " name = 'foo',", " manifest = 'AndroidManifest.xml',", " deps = [':lib'],", " feature_flags = {", " 'flag1': 'on',", " },", " transitive_configs = [':flag1', ':flag2'],", ")"); ConfiguredTarget binary = getConfiguredTarget("//java/com/foo"); List<String> inputs = prettyArtifactNames(actionsTestUtil().artifactClosureOf(getFinalUnsignedApk(binary))); assertThat(inputs).containsAtLeast("java/com/foo/Flag1On.java", "java/com/foo/Flag2Off.java"); assertThat(inputs).containsNoneOf("java/com/foo/Flag1Off.java", "java/com/foo/Flag2On.java"); } @Test public void testFeatureFlagsAttributeSetsSelectInBinary() throws Exception { useConfiguration( "--experimental_dynamic_configs=notrim", "--enforce_transitive_configs_for_config_feature_flag"); scratch.file( "java/com/foo/BUILD", "config_feature_flag(", " name = 'flag1',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "config_setting(", " name = 'flag1@on',", " flag_values = {':flag1': 'on'},", " transitive_configs = [':flag1'],", ")", "config_feature_flag(", " name = 'flag2',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "config_setting(", " name = 'flag2@on',", " flag_values = {':flag2': 'on'},", " transitive_configs = [':flag2'],", ")", "android_binary(", " name = 'foo',", " manifest = 'AndroidManifest.xml',", " srcs = select({", " ':flag1@on': ['Flag1On.java'],", " '//conditions:default': ['Flag1Off.java'],", " }) + select({", " ':flag2@on': ['Flag2On.java'],", " '//conditions:default': ['Flag2Off.java'],", " }),", " feature_flags = {", " 'flag1': 'on',", " },", " transitive_configs = [':flag1', ':flag2'],", ")"); ConfiguredTarget binary = getConfiguredTarget("//java/com/foo"); List<String> inputs = prettyArtifactNames(actionsTestUtil().artifactClosureOf(getFinalUnsignedApk(binary))); assertThat(inputs).containsAtLeast("java/com/foo/Flag1On.java", "java/com/foo/Flag2Off.java"); assertThat(inputs).containsNoneOf("java/com/foo/Flag1Off.java", "java/com/foo/Flag2On.java"); } @Test public void testFeatureFlagsAttributeSetsSelectInBinaryAlias() throws Exception { useConfiguration( "--experimental_dynamic_configs=notrim", "--enforce_transitive_configs_for_config_feature_flag"); scratch.file( "java/com/foo/BUILD", "config_feature_flag(", " name = 'flag1',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "config_setting(", " name = 'flag1@on',", " flag_values = {':flag1': 'on'},", " transitive_configs = [':flag1'],", ")", "android_binary(", " name = 'foo',", " manifest = 'AndroidManifest.xml',", " srcs = select({", " ':flag1@on': ['Flag1On.java'],", " '//conditions:default': ['Flag1Off.java'],", " }),", " feature_flags = {", " 'flag1': 'on',", " },", " transitive_configs = [':flag1'],", ")", "alias(", " name = 'alias',", " actual = ':foo',", ")"); ConfiguredTarget binary = getConfiguredTarget("//java/com/foo:alias"); List<String> inputs = prettyArtifactNames(actionsTestUtil().artifactClosureOf(getFinalUnsignedApk(binary))); assertThat(inputs).contains("java/com/foo/Flag1On.java"); assertThat(inputs).doesNotContain("java/com/foo/Flag1Off.java"); } @Test public void testFeatureFlagsAttributeFailsAnalysisIfFlagValueIsInvalid() throws Exception { reporter.removeHandler(failFastHandler); useConfiguration( "--experimental_dynamic_configs=on", "--enforce_transitive_configs_for_config_feature_flag"); scratch.file( "java/com/foo/BUILD", "config_feature_flag(", " name = 'flag1',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "config_setting(", " name = 'flag1@on',", " flag_values = {':flag1': 'on'},", " transitive_configs = [':flag1'],", ")", "android_library(", " name = 'lib',", " srcs = select({", " ':flag1@on': ['Flag1On.java'],", " '//conditions:default': ['Flag1Off.java'],", " }),", " transitive_configs = [':flag1'],", ")", "android_binary(", " name = 'foo',", " manifest = 'AndroidManifest.xml',", " deps = [':lib'],", " feature_flags = {", " 'flag1': 'invalid',", " },", " transitive_configs = [':flag1'],", ")"); assertThat(getConfiguredTarget("//java/com/foo")).isNull(); assertContainsEvent( "in config_feature_flag rule //java/com/foo:flag1: " + "value must be one of [\"off\", \"on\"], but was \"invalid\""); } @Test public void testFeatureFlagsAttributeFailsAnalysisIfFlagValueIsInvalidEvenIfNotUsed() throws Exception { reporter.removeHandler(failFastHandler); useConfiguration( "--experimental_dynamic_configs=on", "--enforce_transitive_configs_for_config_feature_flag"); scratch.file( "java/com/foo/BUILD", "config_feature_flag(", " name = 'flag1',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "config_setting(", " name = 'flag1@on',", " flag_values = {':flag1': 'on'},", " transitive_configs = [':flag1'],", ")", "android_binary(", " name = 'foo',", " manifest = 'AndroidManifest.xml',", " feature_flags = {", " 'flag1': 'invalid',", " },", " transitive_configs = [':flag1'],", ")"); assertThat(getConfiguredTarget("//java/com/foo")).isNull(); assertContainsEvent( "in config_feature_flag rule //java/com/foo:flag1: " + "value must be one of [\"off\", \"on\"], but was \"invalid\""); } @Test public void testFeatureFlagsAttributeFailsAnalysisIfFlagIsAliased() throws Exception { reporter.removeHandler(failFastHandler); useConfiguration( "--experimental_dynamic_configs=notrim", "--enforce_transitive_configs_for_config_feature_flag"); scratch.file( "java/com/foo/BUILD", "config_feature_flag(", " name = 'flag1',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "alias(", " name = 'alias',", " actual = 'flag1',", " transitive_configs = [':flag1'],", ")", "android_binary(", " name = 'foo',", " manifest = 'AndroidManifest.xml',", " feature_flags = {", " 'alias': 'on',", " },", " transitive_configs = [':flag1'],", ")"); assertThat(getConfiguredTarget("//java/com/foo")).isNull(); assertContainsEvent( "in feature_flags attribute of android_binary rule //java/com/foo:foo: " + "Feature flags must be named directly, not through aliases; " + "use '//java/com/foo:flag1', not '//java/com/foo:alias'"); } @Test public void testFeatureFlagsAttributeSetsFeatureFlagProviderValues() throws Exception { useConfiguration( "--experimental_dynamic_configs=notrim", "--enforce_transitive_configs_for_config_feature_flag"); scratch.file( "java/com/foo/reader.bzl", "def _impl(ctx):", " ctx.actions.write(", " ctx.outputs.java,", " '\\n'.join([", " str(target.label) + ': ' + target[config_common.FeatureFlagInfo].value", " for target in ctx.attr.flags]))", " return [DefaultInfo(files=depset([ctx.outputs.java]))]", "flag_reader = rule(", " implementation=_impl,", " attrs={'flags': attr.label_list(providers=[config_common.FeatureFlagInfo])},", " outputs={'java': '%{name}.java'},", ")"); scratch.file( "java/com/foo/BUILD", "load('//java/com/foo:reader.bzl', 'flag_reader')", "config_feature_flag(", " name = 'flag1',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "config_feature_flag(", " name = 'flag2',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "flag_reader(", " name = 'FooFlags',", " flags = [':flag1', ':flag2'],", " transitive_configs = [':flag1', ':flag2'],", ")", "android_binary(", " name = 'foo',", " manifest = 'AndroidManifest.xml',", " srcs = [':FooFlags.java'],", " feature_flags = {", " 'flag1': 'on',", " },", " transitive_configs = [':flag1', ':flag2'],", ")"); Artifact flagList = getFirstArtifactEndingWith( actionsTestUtil() .artifactClosureOf(getFinalUnsignedApk(getConfiguredTarget("//java/com/foo"))), "/FooFlags.java"); FileWriteAction action = (FileWriteAction) getGeneratingAction(flagList); assertThat(action.getFileContents()) .isEqualTo("//java/com/foo:flag1: on\n//java/com/foo:flag2: off"); } @Test public void testNocompressExtensions() throws Exception { scratch.file( "java/r/android/BUILD", "android_binary(", " name = 'r',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/raw/foo.apk'],", " nocompress_extensions = ['.apk', '.so'],", ")"); ConfiguredTarget binary = getConfiguredTarget("//java/r/android:r"); ValidatedAndroidResources resource = getValidatedResources(binary); List<String> args = resourceArguments(resource); Artifact inputManifest = getFirstArtifactEndingWith( getGeneratingSpawnAction(resource.getManifest()).getInputs(), "AndroidManifest.xml"); assertContainsSublist( args, ImmutableList.of( "--primaryData", "java/r/android/res::" + inputManifest.getExecPathString())); assertThat(args).contains("--uncompressedExtensions"); assertThat(args.get(args.indexOf("--uncompressedExtensions") + 1)).isEqualTo(".apk,.so"); assertThat(getGeneratingSpawnActionArgs(getCompressedUnsignedApk(binary))) .containsAtLeast("--nocompress_suffixes", ".apk", ".so") .inOrder(); assertThat(getGeneratingSpawnActionArgs(getFinalUnsignedApk(binary))) .containsAtLeast("--nocompress_suffixes", ".apk", ".so") .inOrder(); } @Test public void testFeatureFlagPolicyMustContainRuleToUseFeatureFlags() throws Exception { reporter.removeHandler(failFastHandler); // expecting an error useConfiguration("--enforce_transitive_configs_for_config_feature_flag"); scratch.overwriteFile( "tools/whitelists/config_feature_flag/BUILD", "package_group(", " name = 'config_feature_flag',", " packages = ['//flag'])"); scratch.file( "flag/BUILD", "config_feature_flag(", " name = 'flag',", " allowed_values = ['right', 'wrong'],", " default_value = 'right',", " visibility = ['//java/com/google/android/foo:__pkg__'],", ")"); scratch.file( "java/com/google/android/foo/BUILD", "android_binary(", " name = 'foo',", " manifest = 'AndroidManifest.xml',", " srcs = [':FooFlags.java'],", " feature_flags = {", " '//flag:flag': 'right',", " },", " transitive_configs = ['//flag:flag'],", ")"); assertThat(getConfiguredTarget("//java/com/google/android/foo:foo")).isNull(); assertContainsEvent( "in feature_flags attribute of android_binary rule //java/com/google/android/foo:foo: " + "the feature_flags attribute is not available in package " + "'java/com/google/android/foo'"); } @Test public void testFeatureFlagPolicyDoesNotBlockRuleIfInPolicy() throws Exception { useConfiguration("--enforce_transitive_configs_for_config_feature_flag"); scratch.overwriteFile( "tools/whitelists/config_feature_flag/BUILD", "package_group(", " name = 'config_feature_flag',", " packages = ['//flag', '//java/com/google/android/foo'])"); scratch.file( "flag/BUILD", "config_feature_flag(", " name = 'flag',", " allowed_values = ['right', 'wrong'],", " default_value = 'right',", " visibility = ['//java/com/google/android/foo:__pkg__'],", ")"); scratch.file( "java/com/google/android/foo/BUILD", "android_binary(", " name = 'foo',", " manifest = 'AndroidManifest.xml',", " srcs = [':FooFlags.java'],", " feature_flags = {", " '//flag:flag': 'right',", " },", " transitive_configs = ['//flag:flag'],", ")"); assertThat(getConfiguredTarget("//java/com/google/android/foo:foo")).isNotNull(); assertNoEvents(); } @Test public void testFeatureFlagPolicyIsNotUsedIfFlagValuesNotUsed() throws Exception { scratch.overwriteFile( "tools/whitelists/config_feature_flag/BUILD", "package_group(", " name = 'config_feature_flag',", " packages = ['*super* busted package group'])"); scratch.file( "java/com/google/android/foo/BUILD", "android_binary(", " name = 'foo',", " manifest = 'AndroidManifest.xml',", " srcs = [':FooFlags.java'],", ")"); assertThat(getConfiguredTarget("//java/com/google/android/foo:foo")).isNotNull(); // the package_group is busted, so we would have failed to get this far if we depended on it assertNoEvents(); // sanity check time: does this test actually test what we're testing for? reporter.removeHandler(failFastHandler); assertThat(getConfiguredTarget("//tools/whitelists/config_feature_flag:config_feature_flag")) .isNull(); assertContainsEvent("*super* busted package group"); } @Test public void testAapt2WithoutAndroidSdk() throws Exception { checkError( "java/a", "a", "aapt2 processing requested but not available on the android_sdk", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = [ 'res/values/values.xml' ], ", " aapt_version = 'aapt2'", ")"); } @Test public void testAapt2FlagWithoutAndroidSdk() throws Exception { useConfiguration("--android_aapt=aapt2"); checkError( "java/a", "a", "aapt2 processing requested but not available on the android_sdk", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = [ 'res/values/values.xml' ], ", ")"); } @Test public void testAapt2WithAndroidSdk() throws Exception { mockAndroidSdkWithAapt2(); scratch.file( "java/a/BUILD", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = [ 'res/values/values.xml' ], ", " aapt_version = 'aapt2'", ")"); useConfiguration("--android_sdk=//sdk:sdk"); ConfiguredTarget a = getConfiguredTarget("//java/a:a"); Artifact apk = getImplicitOutputArtifact(a, AndroidRuleClasses.ANDROID_RESOURCES_APK); assertThat(getGeneratingSpawnActionArgs(apk)) .containsAtLeast("--aapt2", "sdk/aapt2", "--tool", "AAPT2_PACKAGE"); } @Test public void testAapt2WithAndroidSdkAndDependencies() throws Exception { mockAndroidSdkWithAapt2(); scratch.file( "java/b/BUILD", "android_library(", " name = 'b',", " srcs = ['B.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = [ 'res/values/values.xml' ], ", ")"); scratch.file( "java/a/BUILD", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " deps = [ '//java/b:b' ],", " resource_files = [ 'res/values/values.xml' ], ", " aapt_version = 'aapt2'", ")"); useConfiguration("--android_sdk=//sdk:sdk"); ConfiguredTarget a = getConfiguredTarget("//java/a:a"); ConfiguredTarget b = getDirectPrerequisite(a, "//java/b:b"); Artifact classJar = getImplicitOutputArtifact(a, AndroidRuleClasses.ANDROID_RESOURCES_CLASS_JAR); Artifact rTxt = getImplicitOutputArtifact(a, AndroidRuleClasses.ANDROID_R_TXT); Artifact apk = getImplicitOutputArtifact(a, AndroidRuleClasses.ANDROID_RESOURCES_APK); SpawnAction apkAction = getGeneratingSpawnAction(apk); assertThat(getGeneratingSpawnActionArgs(apk)) .containsAtLeast("--aapt2", "sdk/aapt2", "--tool", "AAPT2_PACKAGE"); assertThat(apkAction.getInputs()) .contains( getImplicitOutputArtifact(b, AndroidRuleClasses.ANDROID_COMPILED_SYMBOLS)); SpawnAction classAction = getGeneratingSpawnAction(classJar); assertThat(classAction.getInputs()) .containsAtLeast( rTxt, getImplicitOutputArtifact(b, AndroidRuleClasses.ANDROID_RESOURCES_AAPT2_R_TXT)); } @Test public void testAapt2ResourceShrinkingAction() throws Exception { mockAndroidSdkWithAapt2(); scratch.file( "java/com/google/android/hello/BUILD", "android_binary(name = 'hello',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " inline_constants = 0,", " aapt_version='aapt2',", " resource_files = ['res/values/strings.xml'],", " shrink_resources = 1,", " proguard_specs = ['proguard-spec.pro'],)"); useConfiguration("--android_sdk=//sdk:sdk"); ConfiguredTargetAndData targetAndData = getConfiguredTargetAndData("//java/com/google/android/hello:hello"); ConfiguredTarget binary = targetAndData.getConfiguredTarget(); Artifact jar = getResourceClassJar(targetAndData); assertThat(getGeneratingAction(jar).getMnemonic()).isEqualTo("RClassGenerator"); assertThat(getGeneratingSpawnActionArgs(jar)).contains("--finalFields"); Set<Artifact> artifacts = actionsTestUtil().artifactClosureOf(getFilesToBuild(binary)); assertThat(artifacts) .containsAtLeast( getFirstArtifactEndingWith(artifacts, "resource_files.zip"), getFirstArtifactEndingWith(artifacts, "proguard.jar"), getFirstArtifactEndingWith(artifacts, "shrunk.ap_")); List<String> processingArgs = getGeneratingSpawnActionArgs(getFirstArtifactEndingWith(artifacts, "resource_files.zip")); assertThat(flagValue("--resourcesOutput", processingArgs)) .endsWith("hello_files/resource_files.zip"); List<String> proguardArgs = getGeneratingSpawnActionArgs(getFirstArtifactEndingWith(artifacts, "proguard.jar")); assertThat(flagValue("-outjars", proguardArgs)).endsWith("hello_proguard.jar"); List<String> shrinkingArgs = getGeneratingSpawnActionArgs(getFirstArtifactEndingWith(artifacts, "shrunk.ap_")); assertThat(flagValue("--tool", shrinkingArgs)).isEqualTo("SHRINK_AAPT2"); assertThat(flagValue("--aapt2", shrinkingArgs)).isEqualTo(flagValue("--aapt2", processingArgs)); assertThat(flagValue("--resources", shrinkingArgs)) .isEqualTo(flagValue("--resourcesOutput", processingArgs)); assertThat(flagValue("--shrunkJar", shrinkingArgs)) .isEqualTo(flagValue("-outjars", proguardArgs)); assertThat(flagValue("--proguardMapping", shrinkingArgs)) .isEqualTo(flagValue("-printmapping", proguardArgs)); assertThat(flagValue("--rTxt", shrinkingArgs)) .isEqualTo(flagValue("--rOutput", processingArgs)); List<String> packageArgs = getGeneratingSpawnActionArgs(getFirstArtifactEndingWith(artifacts, "_hello_proguard.cfg")); assertThat(flagValue("--tool", packageArgs)).isEqualTo("AAPT2_PACKAGE"); assertThat(packageArgs).doesNotContain("--conditionalKeepRules"); } @Test public void testAapt2ResourceCycleShrinking() throws Exception { mockAndroidSdkWithAapt2(); useConfiguration( "--android_sdk=//sdk:sdk", "--experimental_android_resource_cycle_shrinking=true"); scratch.file( "java/com/google/android/hello/BUILD", "android_binary(name = 'hello',", " srcs = ['Foo.java'],", " manifest = 'AndroidManifest.xml',", " inline_constants = 0,", " aapt_version='aapt2',", " resource_files = ['res/values/strings.xml'],", " shrink_resources = 1,", " proguard_specs = ['proguard-spec.pro'],)"); ConfiguredTargetAndData targetAndData = getConfiguredTargetAndData("//java/com/google/android/hello:hello"); ConfiguredTarget binary = targetAndData.getConfiguredTarget(); Artifact jar = getResourceClassJar(targetAndData); assertThat(getGeneratingAction(jar).getMnemonic()).isEqualTo("RClassGenerator"); assertThat(getGeneratingSpawnActionArgs(jar)).contains("--nofinalFields"); Set<Artifact> artifacts = actionsTestUtil().artifactClosureOf(getFilesToBuild(binary)); List<String> packageArgs = getGeneratingSpawnActionArgs(getFirstArtifactEndingWith(artifacts, "_hello_proguard.cfg")); assertThat(flagValue("--tool", packageArgs)).isEqualTo("AAPT2_PACKAGE"); assertThat(packageArgs).contains("--conditionalKeepRules"); } @Test public void testAapt2ResourceCycleShinkingWithoutResourceShrinking() throws Exception { mockAndroidSdkWithAapt2(); useConfiguration( "--android_sdk=//sdk:sdk", "--experimental_android_resource_cycle_shrinking=true"); checkError( "java/a", "a", "resource cycle shrinking can only be enabled when resource shrinking is enabled", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = [ 'res/values/values.xml' ], ", " shrink_resources = 0,", " aapt_version = 'aapt2'", ")"); } @Test public void testDebugKeyExistsBinary() throws Exception { String debugKeyTarget = "//java/com/google/android/hello:debug_keystore"; scratch.file("java/com/google/android/hello/debug_keystore", "A debug key"); scratch.file( "java/com/google/android/hello/BUILD", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " manifest = 'AndroidManifest.xml',", " debug_key = '" + debugKeyTarget + "')"); checkDebugKey(debugKeyTarget, true); } @Test public void testDebugKeyNotExistsBinary() throws Exception { String debugKeyTarget = "//java/com/google/android/hello:debug_keystore"; scratch.file( "java/com/google/android/hello/BUILD", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " manifest = 'AndroidManifest.xml')"); checkDebugKey(debugKeyTarget, false); } @Test public void testOnlyProguardSpecs() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_library(name = 'l2',", " srcs = ['MoreMaps.java'],", " neverlink = 1)", "android_library(name = 'l3',", " idl_srcs = ['A.aidl'],", " deps = [':l2'])", "android_library(name = 'l4',", " srcs = ['SubMoreMaps.java'],", " neverlink = 1)", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " deps = [':l3', ':l4'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard-spec.pro', 'proguard-spec1.pro',", " 'proguard-spec2.pro'])"); checkProguardUse( "//java/com/google/android/hello:b", "b_proguard.jar", false, null, targetConfig.getBinFragment() + "/java/com/google/android/hello/proguard/b/legacy_b_combined_library_jars.jar"); } @Test public void testOnlyProguardSpecsProguardJar() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_library(name = 'l2',", " srcs = ['MoreMaps.java'],", " neverlink = 1)", "android_library(name = 'l3',", " idl_srcs = ['A.aidl'],", " deps = [':l2'])", "android_library(name = 'l4',", " srcs = ['SubMoreMaps.java'],", " neverlink = 1)", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " deps = [':l3', ':l4'],", " manifest = 'AndroidManifest.xml',", " proguard_generate_mapping = 1,", " proguard_specs = ['proguard-spec.pro', 'proguard-spec1.pro',", " 'proguard-spec2.pro'])"); ConfiguredTarget output = getConfiguredTarget("//java/com/google/android/hello:b_proguard.jar"); assertProguardUsed(output); output = getConfiguredTarget("//java/com/google/android/hello:b_proguard.map"); assertWithMessage("proguard.map is not in the rule output") .that( actionsTestUtil() .getActionForArtifactEndingWith(getFilesToBuild(output), "_proguard.map")) .isNotNull(); } @Test public void testCommandLineForMultipleProguardSpecs() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_library(name = 'l1',", " srcs = ['Maps.java'],", " neverlink = 1)", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " deps = [':l1'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard-spec.pro', 'proguard-spec1.pro',", " 'proguard-spec2.pro'])"); ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android/hello:b"); SpawnAction action = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( getFilesToBuild(binary), "_proguard.jar"); assertWithMessage("Proguard action does not contain expected inputs.") .that(prettyArtifactNames(action.getInputs())) .containsAtLeast( "java/com/google/android/hello/proguard-spec.pro", "java/com/google/android/hello/proguard-spec1.pro", "java/com/google/android/hello/proguard-spec2.pro"); assertThat(action.getArguments()) .containsExactly( getProguardBinary().getExecPathString(), "-forceprocessing", "-injars", execPathEndingWith(action.getInputs(), "b_deploy.jar"), "-outjars", execPathEndingWith(action.getOutputs(), "b_proguard.jar"), // Only one combined library jar "-libraryjars", execPathEndingWith(action.getInputs(), "legacy_b_combined_library_jars.jar"), "@" + execPathEndingWith(action.getInputs(), "b_proguard.cfg"), "@java/com/google/android/hello/proguard-spec.pro", "@java/com/google/android/hello/proguard-spec1.pro", "@java/com/google/android/hello/proguard-spec2.pro", "-printseeds", execPathEndingWith(action.getOutputs(), "_proguard.seeds"), "-printusage", execPathEndingWith(action.getOutputs(), "_proguard.usage"), "-printconfiguration", execPathEndingWith(action.getOutputs(), "_proguard.config")) .inOrder(); } /** Regression test for b/17790639 */ @Test public void testNoDuplicatesInProguardCommand() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_library(name = 'l1',", " srcs = ['Maps.java'],", " neverlink = 1)", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " deps = [':l1'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard-spec.pro', 'proguard-spec1.pro',", " 'proguard-spec2.pro'])"); ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android/hello:b"); SpawnAction action = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( getFilesToBuild(binary), "_proguard.jar"); assertThat(action.getArguments()) .containsExactly( getProguardBinary().getExecPathString(), "-forceprocessing", "-injars", execPathEndingWith(action.getInputs(), "b_deploy.jar"), "-outjars", execPathEndingWith(action.getOutputs(), "b_proguard.jar"), // Only one combined library jar "-libraryjars", execPathEndingWith(action.getInputs(), "legacy_b_combined_library_jars.jar"), "@" + execPathEndingWith(action.getInputs(), "b_proguard.cfg"), "@java/com/google/android/hello/proguard-spec.pro", "@java/com/google/android/hello/proguard-spec1.pro", "@java/com/google/android/hello/proguard-spec2.pro", "-printseeds", execPathEndingWith(action.getOutputs(), "_proguard.seeds"), "-printusage", execPathEndingWith(action.getOutputs(), "_proguard.usage"), "-printconfiguration", execPathEndingWith(action.getOutputs(), "_proguard.config")) .inOrder(); } @Test public void testProguardMapping() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard-spec.pro'],", " proguard_generate_mapping = 1)"); checkProguardUse( "//java/com/google/android/hello:b", "b_proguard.jar", true, null, getAndroidJarPath()); } @Test public void testProguardMappingProvider() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_library(name = 'l2',", " srcs = ['MoreMaps.java'],", " neverlink = 1)", "android_library(name = 'l3',", " idl_srcs = ['A.aidl'],", " deps = [':l2'])", "android_library(name = 'l4',", " srcs = ['SubMoreMaps.java'],", " neverlink = 1)", "android_binary(name = 'b1',", " srcs = ['HelloApp.java'],", " deps = [':l3', ':l4'],", " manifest = 'AndroidManifest.xml',", " proguard_generate_mapping = 1,", " proguard_specs = ['proguard-spec.pro', 'proguard-spec1.pro',", " 'proguard-spec2.pro'])", "android_binary(name = 'b2',", " srcs = ['HelloApp.java'],", " deps = [':l3', ':l4'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard-spec.pro', 'proguard-spec1.pro',", " 'proguard-spec2.pro'])"); ConfiguredTarget output = getConfiguredTarget("//java/com/google/android/hello:b1"); assertProguardUsed(output); Artifact mappingArtifact = getBinArtifact("b1_proguard.map", output); ProguardMappingProvider mappingProvider = output.get(ProguardMappingProvider.PROVIDER); assertThat(mappingProvider.getProguardMapping()).isEqualTo(mappingArtifact); output = getConfiguredTarget("//java/com/google/android/hello:b2"); assertProguardUsed(output); assertThat(output.get(ProguardMappingProvider.PROVIDER)).isNull(); } @Test public void testLegacyOptimizationModeUsesExtraProguardSpecs() throws Exception { useConfiguration("--extra_proguard_specs=java/com/google/android/hello:extra.pro"); scratch.file("java/com/google/android/hello/BUILD", "exports_files(['extra.pro'])", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard-spec.pro'])"); checkProguardUse( "//java/com/google/android/hello:b", "b_proguard.jar", false, null, getAndroidJarPath()); SpawnAction action = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( getFilesToBuild(getConfiguredTarget("//java/com/google/android/hello:b")), "_proguard.jar"); assertThat(prettyArtifactNames(action.getInputs())).containsNoDuplicates(); assertThat(Collections2.filter(action.getArguments(), arg -> arg.startsWith("@"))) .containsExactly( "@" + execPathEndingWith(action.getInputs(), "/proguard-spec.pro"), "@" + execPathEndingWith(action.getInputs(), "/_b_proguard.cfg"), "@java/com/google/android/hello/extra.pro"); } @Test public void testExtraProguardSpecsDontDuplicateProguardInputFiles() throws Exception { useConfiguration("--extra_proguard_specs=java/com/google/android/hello:proguard-spec.pro"); scratch.file("java/com/google/android/hello/BUILD", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard-spec.pro'])"); checkProguardUse( "//java/com/google/android/hello:b", "b_proguard.jar", false, null, getAndroidJarPath()); SpawnAction action = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( getFilesToBuild(getConfiguredTarget("//java/com/google/android/hello:b")), "_proguard.jar"); assertThat(prettyArtifactNames(action.getInputs())).containsNoDuplicates(); assertThat(Collections2.filter(action.getArguments(), arg -> arg.startsWith("@"))) .containsExactly( "@java/com/google/android/hello/proguard-spec.pro", "@" + execPathEndingWith(action.getInputs(), "/_b_proguard.cfg")); } @Test public void testLegacyLinkingProguardNotUsedWithoutSpecOnBinary() throws Exception { useConfiguration( "--java_optimization_mode=legacy", "--extra_proguard_specs=//java/com/google/android/hello:ignored.pro"); scratch.file("java/com/google/android/hello/BUILD", "exports_files(['ignored.pro'])", "android_library(name = 'l2',", " srcs = ['MoreMaps.java'],", " neverlink = 1)", "android_library(name = 'l3',", " idl_srcs = ['A.aidl'],", // Having a library spec should not trigger proguard on the binary target. " proguard_specs = ['library_spec.cfg'],", " deps = [':l2'])", "android_library(name = 'l4',", " srcs = ['SubMoreMaps.java'],", " neverlink = 1)", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " deps = [':l3', ':l4'],", " manifest = 'AndroidManifest.xml',)"); assertProguardNotUsed(getConfiguredTarget("//java/com/google/android/hello:b")); } @Test public void testFullOptimizationModeForcesProguard() throws Exception { useConfiguration("--java_optimization_mode=optimize_minify"); SpawnAction action = testProguardOptimizationMode(); // Expect spec generated from resources as well as library's (validated) spec as usual assertThat(Collections2.filter(action.getArguments(), arg -> arg.startsWith("@"))) .containsExactly( "@" + execPathEndingWith(action.getInputs(), "/_b_proguard.cfg"), "@" + execPathEndingWith(action.getInputs(), "library_spec.cfg_valid")); } @Test public void testOptimizingModesIncludeExtraProguardSpecs() throws Exception { useConfiguration( "--java_optimization_mode=fast_minify", "--extra_proguard_specs=//java/com/google/android/hello:extra.pro"); SpawnAction action = testProguardOptimizationMode(); assertThat(action.getArguments()).contains("@java/com/google/android/hello/extra.pro"); } @Test public void testRenameModeForcesProguardWithSpecForMode() throws Exception { testProguardPartialOptimizationMode("rename", "-dontshrink\n-dontoptimize\n"); } @Test public void testMinimizingModeForcesProguardWithSpecForMode() throws Exception { testProguardPartialOptimizationMode("fast_minify", "-dontoptimize\n"); } public void testProguardPartialOptimizationMode(String mode, String expectedSpecForMode) throws Exception { useConfiguration("--java_optimization_mode=" + mode); SpawnAction action = testProguardOptimizationMode(); // Expect spec generated from resources, library's (validated) spec, and spec for mode String modeSpecFileSuffix = "/" + mode + "_b_proguard.cfg"; assertThat(Collections2.filter(action.getArguments(), arg -> arg.startsWith("@"))) .containsExactly( "@" + execPathEndingWith(action.getInputs(), modeSpecFileSuffix), "@" + execPathEndingWith(action.getInputs(), "/_b_proguard.cfg"), "@" + execPathEndingWith(action.getInputs(), "library_spec.cfg_valid")); FileWriteAction modeSpec = (FileWriteAction) actionsTestUtil().getActionForArtifactEndingWith( action.getInputs(), modeSpecFileSuffix); assertThat(modeSpec.getFileContents()).isEqualTo(expectedSpecForMode); } public SpawnAction testProguardOptimizationMode() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "exports_files(['extra.pro'])", "android_library(name = 'l',", " idl_srcs = ['A.aidl'],", " proguard_specs = ['library_spec.cfg'])", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " deps = [':l'],", " manifest = 'AndroidManifest.xml',)"); checkProguardUse( "//java/com/google/android/hello:b", "b_proguard.jar", /*expectMapping*/ true, /*passes*/ null, getAndroidJarPath()); SpawnAction action = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( getFilesToBuild(getConfiguredTarget("//java/com/google/android/hello:b")), "_proguard.jar"); assertThat(prettyArtifactNames(action.getInputs())).containsNoDuplicates(); return action; } @Test public void testProguardSpecFromLibraryUsedInBinary() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_library(name = 'l2',", " srcs = ['MoreMaps.java'],", " proguard_specs = ['library_spec.cfg'])", "android_library(name = 'l3',", " idl_srcs = ['A.aidl'],", " proguard_specs = ['library_spec.cfg'],", " deps = [':l2'])", "android_library(name = 'l4',", " srcs = ['SubMoreMaps.java'],", " neverlink = 1)", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " deps = [':l3', ':l4'],", " proguard_specs = ['proguard-spec.pro'],", " manifest = 'AndroidManifest.xml',)"); assertProguardUsed(getConfiguredTarget("//java/com/google/android/hello:b")); assertProguardGenerated(getConfiguredTarget("//java/com/google/android/hello:b")); SpawnAction action = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( getFilesToBuild(getConfiguredTarget("//java/com/google/android/hello:b")), "_proguard.jar"); assertThat(prettyArtifactNames(action.getInputs())) .contains("java/com/google/android/hello/proguard-spec.pro"); assertThat(prettyArtifactNames(action.getInputs())) .contains( "java/com/google/android/hello/validated_proguard/l2/java/com/google/android/hello/library_spec.cfg_valid"); assertThat(prettyArtifactNames(action.getInputs())).containsNoDuplicates(); } @Test public void testResourcesUsedInProguardGenerate() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = ['res/values/strings.xml'],", " proguard_specs = ['proguard-spec.pro', 'proguard-spec1.pro',", " 'proguard-spec2.pro'])"); scratch.file("java/com/google/android/hello/res/values/strings.xml", "<resources><string name = 'hello'>Hello Android!</string></resources>"); ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android/hello:b"); SpawnAction action = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( actionsTestUtil().artifactClosureOf(getFilesToBuild(binary)), "_proguard.cfg"); assertProguardGenerated(binary); assertWithMessage("Generate proguard action does not contain expected input.") .that(prettyArtifactNames(action.getInputs())) .contains("java/com/google/android/hello/res/values/strings.xml"); } @Test public void testUseSingleJarForLibraryJars() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_library(name = 'l1',", " srcs = ['Maps.java'],", " neverlink = 1)", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " deps = [':l1'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard-spec.pro', 'proguard-spec1.pro',", " 'proguard-spec2.pro'])"); ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android/hello:b"); SpawnAction action = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( getFilesToBuild(binary), "_proguard.jar"); checkProguardLibJars(action, targetConfig.getBinFragment() + "/java/com/google/android/hello/proguard/b/legacy_b_combined_library_jars.jar"); } @Test public void testOnlyOneLibraryJar() throws Exception { scratch.file("java/com/google/android/hello/BUILD", "android_binary(name = 'b',", " srcs = ['HelloApp.java'],", " manifest = 'AndroidManifest.xml',", " proguard_specs = ['proguard-spec.pro'],", " proguard_generate_mapping = 1)"); ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android/hello:b"); SpawnAction action = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith( getFilesToBuild(binary), "_proguard.jar"); checkProguardLibJars(action, getAndroidJarPath()); } @Test public void testApkInfoAccessibleFromSkylark() throws Exception { scratch.file( "java/com/google/android/BUILD", "load(':postprocess.bzl', 'postprocess')", "android_binary(name = 'b1',", " srcs = ['b1.java'],", " manifest = 'AndroidManifest.xml')", "postprocess(name = 'postprocess', dep = ':b1')"); scratch.file( "java/com/google/android/postprocess.bzl", "def _impl(ctx):", " return [DefaultInfo(files=depset([ctx.attr.dep[ApkInfo].signed_apk]))]", "postprocess = rule(implementation=_impl,", " attrs={'dep': attr.label(providers=[ApkInfo])})"); ConfiguredTarget postprocess = getConfiguredTarget("//java/com/google/android:postprocess"); assertThat(postprocess).isNotNull(); assertThat( prettyArtifactNames(postprocess.getProvider(FilesToRunProvider.class).getFilesToRun())) .containsExactly("java/com/google/android/b1.apk"); } @Test public void testInstrumentationInfoAccessibleFromSkylark() throws Exception { scratch.file( "java/com/google/android/instr/BUILD", "load(':instr.bzl', 'instr')", "android_binary(name = 'b1',", " srcs = ['b1.java'],", " instruments = ':b2',", " manifest = 'AndroidManifest.xml')", "android_binary(name = 'b2',", " srcs = ['b2.java'],", " manifest = 'AndroidManifest.xml')", "instr(name = 'instr', dep = ':b1')"); scratch.file( "java/com/google/android/instr/instr.bzl", "def _impl(ctx):", " target = ctx.attr.dep[AndroidInstrumentationInfo].target_apk", " instr = ctx.attr.dep[AndroidInstrumentationInfo].instrumentation_apk", " return [DefaultInfo(files=depset([target,instr]))]", "instr = rule(implementation=_impl,", " attrs={'dep': attr.label(providers=[AndroidInstrumentationInfo])})"); ConfiguredTarget instr = getConfiguredTarget("//java/com/google/android/instr"); assertThat(instr).isNotNull(); assertThat(prettyArtifactNames(instr.getProvider(FilesToRunProvider.class).getFilesToRun())) .containsExactly( "java/com/google/android/instr/b1.apk", "java/com/google/android/instr/b2.apk"); } @Test public void testInstrumentationInfoCreatableFromSkylark() throws Exception { scratch.file( "java/com/google/android/instr/BUILD", "load(':instr.bzl', 'instr')", "android_binary(name = 'b1',", " srcs = ['b1.java'],", " instruments = ':b2',", " manifest = 'AndroidManifest.xml')", "android_binary(name = 'b2',", " srcs = ['b2.java'],", " manifest = 'AndroidManifest.xml')", "instr(name = 'instr', dep = ':b1')"); scratch.file( "java/com/google/android/instr/instr.bzl", "def _impl(ctx):", " target = ctx.attr.dep[AndroidInstrumentationInfo].target_apk", " instr = ctx.attr.dep[AndroidInstrumentationInfo].instrumentation_apk", " return [AndroidInstrumentationInfo(target_apk=target,instrumentation_apk=instr)]", "instr = rule(implementation=_impl,", " attrs={'dep': attr.label(providers=[AndroidInstrumentationInfo])})"); ConfiguredTarget instr = getConfiguredTarget("//java/com/google/android/instr"); assertThat(instr).isNotNull(); assertThat(instr.get(AndroidInstrumentationInfo.PROVIDER).getTargetApk().prettyPrint()) .isEqualTo("java/com/google/android/instr/b2.apk"); assertThat(instr.get(AndroidInstrumentationInfo.PROVIDER).getInstrumentationApk().prettyPrint()) .isEqualTo("java/com/google/android/instr/b1.apk"); } @Test public void testInstrumentationInfoProviderHasApks() throws Exception { scratch.file( "java/com/google/android/instr/BUILD", "android_binary(name = 'b1',", " srcs = ['b1.java'],", " instruments = ':b2',", " manifest = 'AndroidManifest.xml')", "android_binary(name = 'b2',", " srcs = ['b2.java'],", " manifest = 'AndroidManifest.xml')"); ConfiguredTarget b1 = getConfiguredTarget("//java/com/google/android/instr:b1"); AndroidInstrumentationInfo provider = b1.get(AndroidInstrumentationInfo.PROVIDER); assertThat(provider.getTargetApk()).isNotNull(); assertThat(provider.getTargetApk().prettyPrint()) .isEqualTo("java/com/google/android/instr/b2.apk"); assertThat(provider.getInstrumentationApk()).isNotNull(); assertThat(provider.getInstrumentationApk().prettyPrint()) .isEqualTo("java/com/google/android/instr/b1.apk"); } @Test public void testNoInstrumentationInfoProviderIfNotInstrumenting() throws Exception { scratch.file( "java/com/google/android/instr/BUILD", "android_binary(name = 'b1',", " srcs = ['b1.java'],", " manifest = 'AndroidManifest.xml')"); ConfiguredTarget b1 = getConfiguredTarget("//java/com/google/android/instr:b1"); AndroidInstrumentationInfo provider = b1.get(AndroidInstrumentationInfo.PROVIDER); assertThat(provider).isNull(); } @Test public void testFilterActionWithInstrumentedBinary() throws Exception { scratch.file( "java/com/google/android/instr/BUILD", "android_binary(name = 'b1',", " srcs = ['b1.java'],", " instruments = ':b2',", " manifest = 'AndroidManifest.xml')", "android_binary(name = 'b2',", " srcs = ['b2.java'],", " manifest = 'AndroidManifest.xml')"); ConfiguredTarget b1 = getConfiguredTarget("//java/com/google/android/instr:b1"); SpawnAction action = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith(getFilesToBuild(b1), "_filtered.jar"); assertThat(action.getArguments()) .containsAtLeast( "--inputZip", getFirstArtifactEndingWith(action.getInputs(), "b1_deploy.jar").getExecPathString(), "--filterZips", getFirstArtifactEndingWith(action.getInputs(), "b2_deploy.jar").getExecPathString(), "--outputZip", getFirstArtifactEndingWith(action.getOutputs(), "b1_filtered.jar").getExecPathString(), "--filterTypes", ".class", "--checkHashMismatch", "IGNORE", "--explicitFilters", "/BR\\.class$,/databinding/[^/]+Binding\\.class$,R\\.class,R\\$.*\\.class", "--outputMode", "DONT_CARE"); } /** * 'proguard_specs' attribute gets read by an implicit outputs function: the * current heuristic is that if this attribute is configurable, we assume its * contents are non-empty and thus create the mybinary_proguard.jar output. * Test that here. */ @Test public void testConfigurableProguardSpecs() throws Exception { scratch.file("conditions/BUILD", "config_setting(", " name = 'a',", " values = {'test_arg': 'a'})", "config_setting(", " name = 'b',", " values = {'test_arg': 'b'})"); scratchConfiguredTarget("java/foo", "abin", "android_binary(", " name = 'abin',", " srcs = ['a.java'],", " proguard_specs = select({", " '//conditions:a': [':file1.pro'],", " '//conditions:b': [],", " '//conditions:default': [':file3.pro'],", " }) + [", // Add a long list here as a regression test for b/68238721 " 'file4.pro',", " 'file5.pro',", " 'file6.pro',", " 'file7.pro',", " 'file8.pro',", " ],", " manifest = 'AndroidManifest.xml')"); checkProguardUse( "//java/foo:abin", "abin_proguard.jar", /*expectMapping=*/ false, /*passes=*/ null, getAndroidJarPath()); } @Test public void testSkipParsingActionFlagGetsPropagated() throws Exception { mockAndroidSdkWithAapt2(); scratch.file( "java/b/BUILD", "android_library(", " name = 'b',", " srcs = ['B.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = [ 'res/values/values.xml' ], ", ")"); scratch.file( "java/a/BUILD", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " deps = [ '//java/b:b' ],", " resource_files = [ 'res/values/values.xml' ], ", " aapt_version = 'aapt2'", ")"); useConfiguration("--android_sdk=//sdk:sdk", "--experimental_skip_parsing_action"); ConfiguredTarget a = getConfiguredTarget("//java/a:a"); ConfiguredTarget b = getDirectPrerequisite(a, "//java/b:b"); List<String> resourceProcessingArgs = getGeneratingSpawnActionArgs(getValidatedResources(a).getApk()); assertThat(resourceProcessingArgs).contains("AAPT2_PACKAGE"); String directData = resourceProcessingArgs.get( resourceProcessingArgs.indexOf("--directData") + 1); assertThat(directData).contains("symbols.zip"); assertThat(directData).doesNotContain("merged.bin"); assertThat(resourceProcessingArgs).contains("--useCompiledResourcesForMerge"); List<String> resourceMergingArgs = getGeneratingSpawnActionArgs(getValidatedResources(b).getJavaClassJar()); assertThat(resourceMergingArgs).contains("MERGE_COMPILED"); } @Test public void alwaysSkipParsingActionWithAapt2() throws Exception { mockAndroidSdkWithAapt2(); scratch.file( "java/b/BUILD", "android_library(", " name = 'b',", " srcs = ['B.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = [ 'res/values/values.xml' ], ", ")"); scratch.file( "java/a/BUILD", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " deps = [ '//java/b:b' ],", " resource_files = [ 'res/values/values.xml' ], ", " aapt_version = 'aapt2'", ")"); useConfiguration("--android_sdk=//sdk:sdk"); ConfiguredTarget a = getConfiguredTarget("//java/a:a"); ConfiguredTarget b = getDirectPrerequisite(a, "//java/b:b"); List<String> resourceProcessingArgs = getGeneratingSpawnActionArgs(getValidatedResources(a).getApk()); assertThat(resourceProcessingArgs).contains("AAPT2_PACKAGE"); String directData = resourceProcessingArgs.get(resourceProcessingArgs.indexOf("--directData") + 1); assertThat(directData).contains("symbols.zip"); assertThat(directData).doesNotContain("merged.bin"); assertThat(resourceProcessingArgs).contains("--useCompiledResourcesForMerge"); // Libraries will still need to merge the xml until skip parsing is on by default. List<String> resourceMergingArgs = getGeneratingSpawnActionArgs(getValidatedResources(b).getJavaClassJar()); assertThat(resourceMergingArgs).contains("MERGE"); } @Test public void testAapt1BuildsWithAapt2Sdk() throws Exception { mockAndroidSdkWithAapt2(); scratch.file( "java/b/BUILD", "android_library(", " name = 'b',", " srcs = ['B.java'],", " manifest = 'AndroidManifest.xml',", " resource_files = [ 'res/values/values.xml' ], ", ")"); scratch.file( "java/a/BUILD", "android_binary(", " name = 'a',", " srcs = ['A.java'],", " manifest = 'AndroidManifest.xml',", " deps = [ '//java/b:b' ],", " resource_files = [ 'res/values/values.xml' ], ", " aapt_version = 'aapt'", ")"); useConfiguration("--android_sdk=//sdk:sdk", "--experimental_skip_parsing_action"); ConfiguredTarget a = getConfiguredTarget("//java/a:a"); ConfiguredTarget b = getDirectPrerequisite(a, "//java/b:b"); List<String> resourceProcessingArgs = getGeneratingSpawnActionArgs(getValidatedResources(a).getRTxt()); assertThat(resourceProcessingArgs).contains("PACKAGE"); String directData = resourceProcessingArgs.get( resourceProcessingArgs.indexOf("--directData") + 1); assertThat(directData).doesNotContain("symbols.zip"); assertThat(directData).contains("merged.bin"); List<String> compiledResourceMergingArgs = getGeneratingSpawnActionArgs(getValidatedResources(b).getJavaClassJar()); assertThat(compiledResourceMergingArgs).contains("MERGE_COMPILED"); Set<Artifact> artifacts = actionsTestUtil().artifactClosureOf(getFilesToBuild(b)); List<String> parsedResourceMergingArgs = getGeneratingSpawnActionArgs(getFirstArtifactEndingWith(artifacts, "resource_files.zip")); assertThat(parsedResourceMergingArgs).contains("MERGE"); } @Test public void skylarkJavaInfoToAndroidBinaryAttributes() throws Exception { scratch.file( "java/r/android/extension.bzl", "def _impl(ctx):", " dep_params = ctx.attr.dep[JavaInfo]", " return [dep_params]", "my_rule = rule(", " _impl,", " attrs = {", " 'dep': attr.label(),", " },", ")"); scratch.file( "java/r/android/BUILD", "load(':extension.bzl', 'my_rule')", "android_library(", " name = 'al_bottom_for_deps',", " srcs = ['java/A.java'],", ")", "my_rule(", " name = 'mya',", " dep = ':al_bottom_for_deps',", ")", "android_binary(", " name = 'foo_app',", " srcs = ['java/B.java'],", " deps = [':mya'],", " manifest = 'AndroidManifest.xml',", // TODO(b/75051107): Remove the following line when fixed. " incremental_dexing = 0,", ")"); // Test that all bottom jars are on the runtime classpath of the app. ConfiguredTarget target = getConfiguredTarget("//java/r/android:foo_app"); Collection<Artifact> transitiveSrcJars = OutputGroupInfo.get(target).getOutputGroup(JavaSemantics.SOURCE_JARS_OUTPUT_GROUP) .toCollection(); assertThat(ActionsTestUtil.baseArtifactNames(transitiveSrcJars)).containsExactly( "libal_bottom_for_deps-src.jar", "libfoo_app-src.jar"); } @Test public void androidManifestMergerOrderAlphabetical_MergeesSortedByExecPath() throws Exception { // Hack: Avoid the Android split transition by turning off fat_apk_cpu/android_cpu. // This is necessary because the transition would change the configuration directory, causing // the manifest paths in the assertion not to match. // TODO(mstaib): Get the library manifests in the same configuration as the binary gets them. useConfiguration( "--fat_apk_cpu=", "--android_cpu=", "--android_manifest_merger_order=alphabetical"); scratch.overwriteFile( "java/android/BUILD", "android_library(", " name = 'core',", " manifest = 'core/AndroidManifest.xml',", " exports_manifest = 1,", " resource_files = ['core/res/values/strings.xml'],", ")", "android_library(", " name = 'utility',", " manifest = 'utility/AndroidManifest.xml',", " exports_manifest = 1,", " resource_files = ['utility/res/values/values.xml'],", " deps = ['//java/common:common'],", ")"); scratch.file( "java/binary/BUILD", "android_binary(", " name = 'application',", " srcs = ['App.java'],", " manifest = 'app/AndroidManifest.xml',", " deps = [':library'],", ")", "android_library(", " name = 'library',", " manifest = 'library/AndroidManifest.xml',", " exports_manifest = 1,", " deps = ['//java/common:theme', '//java/android:utility'],", ")"); scratch.file( "java/common/BUILD", "android_library(", " name = 'common',", " manifest = 'common/AndroidManifest.xml',", " exports_manifest = 1,", " resource_files = ['common/res/values/common.xml'],", " deps = ['//java/android:core'],", ")", "android_library(", " name = 'theme',", " manifest = 'theme/AndroidManifest.xml',", " exports_manifest = 1,", " resource_files = ['theme/res/values/values.xml'],", ")"); Artifact androidCoreManifest = getLibraryManifest(getConfiguredTarget("//java/android:core")); Artifact androidUtilityManifest = getLibraryManifest(getConfiguredTarget("//java/android:utility")); Artifact binaryLibraryManifest = getLibraryManifest(getConfiguredTarget("//java/binary:library")); Artifact commonManifest = getLibraryManifest(getConfiguredTarget("//java/common:common")); Artifact commonThemeManifest = getLibraryManifest(getConfiguredTarget("//java/common:theme")); assertThat(getBinaryMergeeManifests(getConfiguredTarget("//java/binary:application"))) .containsExactlyEntriesIn( ImmutableMap.of( androidCoreManifest.getExecPath().toString(), "//java/android:core", androidUtilityManifest.getExecPath().toString(), "//java/android:utility", binaryLibraryManifest.getExecPath().toString(), "//java/binary:library", commonManifest.getExecPath().toString(), "//java/common:common", commonThemeManifest.getExecPath().toString(), "//java/common:theme")) .inOrder(); } @Test public void androidManifestMergerOrderAlphabeticalByConfiguration_MergeesSortedByPathInBinOrGen() throws Exception { // Hack: Avoid the Android split transition by turning off fat_apk_cpu/android_cpu. // This is necessary because the transition would change the configuration directory, causing // the manifest paths in the assertion not to match. // TODO(mstaib): Get the library manifests in the same configuration as the binary gets them. useConfiguration( "--fat_apk_cpu=", "--android_cpu=", "--android_manifest_merger_order=alphabetical_by_configuration"); scratch.overwriteFile( "java/android/BUILD", "android_library(", " name = 'core',", " manifest = 'core/AndroidManifest.xml',", " exports_manifest = 1,", " resource_files = ['core/res/values/strings.xml'],", ")", "android_library(", " name = 'utility',", " manifest = 'utility/AndroidManifest.xml',", " exports_manifest = 1,", " resource_files = ['utility/res/values/values.xml'],", " deps = ['//java/common:common'],", " transitive_configs = ['//flags:a', '//flags:b'],", ")"); scratch.file( "java/binary/BUILD", "android_binary(", " name = 'application',", " srcs = ['App.java'],", " manifest = 'app/AndroidManifest.xml',", " deps = [':library'],", " feature_flags = {", " '//flags:a': 'on',", " '//flags:b': 'on',", " '//flags:c': 'on',", " },", " transitive_configs = ['//flags:a', '//flags:b', '//flags:c'],", ")", "android_library(", " name = 'library',", " manifest = 'library/AndroidManifest.xml',", " exports_manifest = 1,", " deps = ['//java/common:theme', '//java/android:utility'],", " transitive_configs = ['//flags:a', '//flags:b', '//flags:c'],", ")"); scratch.file( "java/common/BUILD", "android_library(", " name = 'common',", " manifest = 'common/AndroidManifest.xml',", " exports_manifest = 1,", " resource_files = ['common/res/values/common.xml'],", " deps = ['//java/android:core'],", " transitive_configs = ['//flags:a'],", ")", "android_library(", " name = 'theme',", " manifest = 'theme/AndroidManifest.xml',", " exports_manifest = 1,", " resource_files = ['theme/res/values/values.xml'],", " transitive_configs = ['//flags:a', '//flags:b', '//flags:c'],", ")"); scratch.file( "flags/BUILD", "config_feature_flag(", " name = 'a',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "config_feature_flag(", " name = 'b',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")", "config_feature_flag(", " name = 'c',", " allowed_values = ['on', 'off'],", " default_value = 'off',", ")"); assertThat(getBinaryMergeeManifests(getConfiguredTarget("//java/binary:application")).values()) .containsExactly( "//java/android:core", "//java/android:utility", "//java/binary:library", "//java/common:common", "//java/common:theme") .inOrder(); } // DEPENDENCY order is not tested; the incorrect order of dependencies means the test would // have to enforce incorrect behavior. // TODO(b/117338320): Add a test when dependency order is fixed. }
81633ccfac2898410b0add0107eb181c03e04ee8
983a178278f21be26a3df50b7f59892cbb53fd1c
/src/structural/facade/subsystem/PhoneProducer.java
7712f3bb02f60048982e0763e02b1b0bbdeee779
[]
no_license
RenatKaitmazov/Design-Patterns
c7397c62cac5239794fcc195f179b98f633d0f81
1d43ed5e8efbb198e176a3c07b1a57d9c263591d
refs/heads/master
2021-01-01T18:24:47.412353
2017-07-28T14:56:56
2017-07-28T14:56:56
98,329,558
0
0
null
null
null
null
UTF-8
Java
false
false
131
java
package structural.facade.subsystem; /** * @author Renat Kaitmazov */ public enum PhoneProducer { APPLE, SAMSUNG, GOOGLE }
f51667b48894860c3134f2fbfcf5de362a2f3025
2f79a91a0fa22d7fb321bc5d32f72d2d165e0863
/android/demo/gen/android/support/v7/appcompat/R.java
308c21dbd67682f98ca1b7c7e94d88e8c92b2834
[]
no_license
jiangzhen1984/SkyWorld
e057b02bf2d8f532f8e359bf580ea177689120f1
409c99453ece4247a9487fa99eaffcbb4a01d411
refs/heads/master
2021-01-21T13:56:59.718395
2016-05-29T06:54:12
2016-05-29T06:54:12
49,647,200
0
0
null
null
null
null
UTF-8
Java
false
false
41,086
java
/* AUTO-GENERATED FILE. DO NOT MODIFY. * * This class was automatically generated by the * aapt tool from the resource data it found. It * should not be modified by hand. */ package android.support.v7.appcompat; public final class R { public static final class anim { public static final int abc_fade_in = 0x7f040000; public static final int abc_fade_out = 0x7f040001; public static final int abc_slide_in_bottom = 0x7f040002; public static final int abc_slide_in_top = 0x7f040003; public static final int abc_slide_out_bottom = 0x7f040004; public static final int abc_slide_out_top = 0x7f040005; } public static final class attr { public static final int actionBarDivider = 0x7f01000f; public static final int actionBarItemBackground = 0x7f010010; public static final int actionBarSize = 0x7f01000e; public static final int actionBarSplitStyle = 0x7f01000c; public static final int actionBarStyle = 0x7f01000b; public static final int actionBarTabBarStyle = 0x7f010008; public static final int actionBarTabStyle = 0x7f010007; public static final int actionBarTabTextStyle = 0x7f010009; public static final int actionBarWidgetTheme = 0x7f01000d; public static final int actionButtonStyle = 0x7f010016; public static final int actionDropDownStyle = 0x7f010047; public static final int actionLayout = 0x7f01004e; public static final int actionMenuTextAppearance = 0x7f010011; public static final int actionMenuTextColor = 0x7f010012; public static final int actionModeBackground = 0x7f01003c; public static final int actionModeCloseButtonStyle = 0x7f01003b; public static final int actionModeCloseDrawable = 0x7f01003e; public static final int actionModeCopyDrawable = 0x7f010040; public static final int actionModeCutDrawable = 0x7f01003f; public static final int actionModeFindDrawable = 0x7f010044; public static final int actionModePasteDrawable = 0x7f010041; public static final int actionModePopupWindowStyle = 0x7f010046; public static final int actionModeSelectAllDrawable = 0x7f010042; public static final int actionModeShareDrawable = 0x7f010043; public static final int actionModeSplitBackground = 0x7f01003d; public static final int actionModeStyle = 0x7f01003a; public static final int actionModeWebSearchDrawable = 0x7f010045; public static final int actionOverflowButtonStyle = 0x7f01000a; public static final int actionProviderClass = 0x7f010050; public static final int actionViewClass = 0x7f01004f; public static final int activityChooserViewStyle = 0x7f01006c; public static final int background = 0x7f01002f; public static final int backgroundSplit = 0x7f010031; public static final int backgroundStacked = 0x7f010030; public static final int buttonBarButtonStyle = 0x7f010018; public static final int buttonBarStyle = 0x7f010017; public static final int customNavigationLayout = 0x7f010032; public static final int disableChildrenWhenDisabled = 0x7f010054; public static final int displayOptions = 0x7f010028; public static final int divider = 0x7f01002e; public static final int dividerHorizontal = 0x7f01001b; public static final int dividerPadding = 0x7f010056; public static final int dividerVertical = 0x7f01001a; public static final int dropDownListViewStyle = 0x7f010021; public static final int dropdownListPreferredItemHeight = 0x7f010048; public static final int expandActivityOverflowButtonDrawable = 0x7f01006b; public static final int height = 0x7f010026; public static final int homeAsUpIndicator = 0x7f010013; public static final int homeLayout = 0x7f010033; public static final int icon = 0x7f01002c; public static final int iconifiedByDefault = 0x7f01005a; public static final int indeterminateProgressStyle = 0x7f010035; public static final int initialActivityCount = 0x7f01006a; public static final int isLightTheme = 0x7f010059; public static final int itemPadding = 0x7f010037; public static final int listChoiceBackgroundIndicator = 0x7f01004c; public static final int listPopupWindowStyle = 0x7f010022; public static final int listPreferredItemHeight = 0x7f01001c; public static final int listPreferredItemHeightLarge = 0x7f01001e; public static final int listPreferredItemHeightSmall = 0x7f01001d; public static final int listPreferredItemPaddingLeft = 0x7f01001f; public static final int listPreferredItemPaddingRight = 0x7f010020; public static final int logo = 0x7f01002d; public static final int navigationMode = 0x7f010027; public static final int paddingEnd = 0x7f010039; public static final int paddingStart = 0x7f010038; public static final int panelMenuListTheme = 0x7f01004b; public static final int panelMenuListWidth = 0x7f01004a; public static final int popupMenuStyle = 0x7f010049; public static final int popupPromptView = 0x7f010053; public static final int progressBarPadding = 0x7f010036; public static final int progressBarStyle = 0x7f010034; public static final int prompt = 0x7f010051; public static final int queryHint = 0x7f01005b; public static final int searchDropdownBackground = 0x7f01005c; public static final int searchResultListItemHeight = 0x7f010065; public static final int searchViewAutoCompleteTextView = 0x7f010069; public static final int searchViewCloseIcon = 0x7f01005d; public static final int searchViewEditQuery = 0x7f010061; public static final int searchViewEditQueryBackground = 0x7f010062; public static final int searchViewGoIcon = 0x7f01005e; public static final int searchViewSearchIcon = 0x7f01005f; public static final int searchViewTextField = 0x7f010063; public static final int searchViewTextFieldRight = 0x7f010064; public static final int searchViewVoiceIcon = 0x7f010060; public static final int selectableItemBackground = 0x7f010019; public static final int showAsAction = 0x7f01004d; public static final int showDividers = 0x7f010055; public static final int spinnerDropDownItemStyle = 0x7f010058; public static final int spinnerMode = 0x7f010052; public static final int spinnerStyle = 0x7f010057; public static final int subtitle = 0x7f010029; public static final int subtitleTextStyle = 0x7f01002b; public static final int textAllCaps = 0x7f01006d; public static final int textAppearanceLargePopupMenu = 0x7f010014; public static final int textAppearanceListItem = 0x7f010023; public static final int textAppearanceListItemSmall = 0x7f010024; public static final int textAppearanceSearchResultSubtitle = 0x7f010067; public static final int textAppearanceSearchResultTitle = 0x7f010066; public static final int textAppearanceSmallPopupMenu = 0x7f010015; public static final int textColorSearchUrl = 0x7f010068; public static final int title = 0x7f010025; public static final int titleTextStyle = 0x7f01002a; public static final int windowActionBar = 0x7f010000; public static final int windowActionBarOverlay = 0x7f010001; public static final int windowFixedHeightMajor = 0x7f010006; public static final int windowFixedHeightMinor = 0x7f010004; public static final int windowFixedWidthMajor = 0x7f010003; public static final int windowFixedWidthMinor = 0x7f010005; public static final int windowSplitActionBar = 0x7f010002; } public static final class bool { public static final int abc_action_bar_embed_tabs_pre_jb = 0x7f090000; public static final int abc_action_bar_expanded_action_views_exclusive = 0x7f090001; public static final int abc_config_actionMenuItemAllCaps = 0x7f090005; public static final int abc_config_allowActionMenuItemTextWithIcon = 0x7f090004; public static final int abc_config_showMenuShortcutsWhenKeyboardPresent = 0x7f090003; public static final int abc_split_action_bar_is_narrow = 0x7f090002; } public static final class color { public static final int abc_search_url_text_holo = 0x7f06007c; public static final int abc_search_url_text_normal = 0x7f060018; public static final int abc_search_url_text_pressed = 0x7f06001a; public static final int abc_search_url_text_selected = 0x7f060019; } public static final class dimen { public static final int abc_action_bar_default_height = 0x7f0a0002; public static final int abc_action_bar_icon_vertical_padding = 0x7f0a0003; public static final int abc_action_bar_progress_bar_size = 0x7f0a000a; public static final int abc_action_bar_stacked_max_height = 0x7f0a0009; public static final int abc_action_bar_stacked_tab_max_width = 0x7f0a0001; public static final int abc_action_bar_subtitle_bottom_margin = 0x7f0a0007; public static final int abc_action_bar_subtitle_text_size = 0x7f0a0005; public static final int abc_action_bar_subtitle_top_margin = 0x7f0a0006; public static final int abc_action_bar_title_text_size = 0x7f0a0004; public static final int abc_action_button_min_width = 0x7f0a0008; public static final int abc_config_prefDialogWidth = 0x7f0a0000; public static final int abc_dropdownitem_icon_width = 0x7f0a0010; public static final int abc_dropdownitem_text_padding_left = 0x7f0a000e; public static final int abc_dropdownitem_text_padding_right = 0x7f0a000f; public static final int abc_panel_menu_list_width = 0x7f0a000b; public static final int abc_search_view_preferred_width = 0x7f0a000d; public static final int abc_search_view_text_min_width = 0x7f0a000c; public static final int dialog_fixed_height_major = 0x7f0a0013; public static final int dialog_fixed_height_minor = 0x7f0a0014; public static final int dialog_fixed_width_major = 0x7f0a0011; public static final int dialog_fixed_width_minor = 0x7f0a0012; } public static final class drawable { public static final int abc_ab_bottom_solid_dark_holo = 0x7f020000; public static final int abc_ab_bottom_solid_light_holo = 0x7f020001; public static final int abc_ab_bottom_transparent_dark_holo = 0x7f020002; public static final int abc_ab_bottom_transparent_light_holo = 0x7f020003; public static final int abc_ab_share_pack_holo_dark = 0x7f020004; public static final int abc_ab_share_pack_holo_light = 0x7f020005; public static final int abc_ab_solid_dark_holo = 0x7f020006; public static final int abc_ab_solid_light_holo = 0x7f020007; public static final int abc_ab_stacked_solid_dark_holo = 0x7f020008; public static final int abc_ab_stacked_solid_light_holo = 0x7f020009; public static final int abc_ab_stacked_transparent_dark_holo = 0x7f02000a; public static final int abc_ab_stacked_transparent_light_holo = 0x7f02000b; public static final int abc_ab_transparent_dark_holo = 0x7f02000c; public static final int abc_ab_transparent_light_holo = 0x7f02000d; public static final int abc_cab_background_bottom_holo_dark = 0x7f02000e; public static final int abc_cab_background_bottom_holo_light = 0x7f02000f; public static final int abc_cab_background_top_holo_dark = 0x7f020010; public static final int abc_cab_background_top_holo_light = 0x7f020011; public static final int abc_ic_ab_back_holo_dark = 0x7f020012; public static final int abc_ic_ab_back_holo_light = 0x7f020013; public static final int abc_ic_cab_done_holo_dark = 0x7f020014; public static final int abc_ic_cab_done_holo_light = 0x7f020015; public static final int abc_ic_clear = 0x7f020016; public static final int abc_ic_clear_disabled = 0x7f020017; public static final int abc_ic_clear_holo_light = 0x7f020018; public static final int abc_ic_clear_normal = 0x7f020019; public static final int abc_ic_clear_search_api_disabled_holo_light = 0x7f02001a; public static final int abc_ic_clear_search_api_holo_light = 0x7f02001b; public static final int abc_ic_commit_search_api_holo_dark = 0x7f02001c; public static final int abc_ic_commit_search_api_holo_light = 0x7f02001d; public static final int abc_ic_go = 0x7f02001e; public static final int abc_ic_go_search_api_holo_light = 0x7f02001f; public static final int abc_ic_menu_moreoverflow_normal_holo_dark = 0x7f020020; public static final int abc_ic_menu_moreoverflow_normal_holo_light = 0x7f020021; public static final int abc_ic_menu_share_holo_dark = 0x7f020022; public static final int abc_ic_menu_share_holo_light = 0x7f020023; public static final int abc_ic_search = 0x7f020024; public static final int abc_ic_search_api_holo_light = 0x7f020025; public static final int abc_ic_voice_search = 0x7f020026; public static final int abc_ic_voice_search_api_holo_light = 0x7f020027; public static final int abc_item_background_holo_dark = 0x7f020028; public static final int abc_item_background_holo_light = 0x7f020029; public static final int abc_list_divider_holo_dark = 0x7f02002a; public static final int abc_list_divider_holo_light = 0x7f02002b; public static final int abc_list_focused_holo = 0x7f02002c; public static final int abc_list_longpressed_holo = 0x7f02002d; public static final int abc_list_pressed_holo_dark = 0x7f02002e; public static final int abc_list_pressed_holo_light = 0x7f02002f; public static final int abc_list_selector_background_transition_holo_dark = 0x7f020030; public static final int abc_list_selector_background_transition_holo_light = 0x7f020031; public static final int abc_list_selector_disabled_holo_dark = 0x7f020032; public static final int abc_list_selector_disabled_holo_light = 0x7f020033; public static final int abc_list_selector_holo_dark = 0x7f020034; public static final int abc_list_selector_holo_light = 0x7f020035; public static final int abc_menu_dropdown_panel_holo_dark = 0x7f020036; public static final int abc_menu_dropdown_panel_holo_light = 0x7f020037; public static final int abc_menu_hardkey_panel_holo_dark = 0x7f020038; public static final int abc_menu_hardkey_panel_holo_light = 0x7f020039; public static final int abc_search_dropdown_dark = 0x7f02003a; public static final int abc_search_dropdown_light = 0x7f02003b; public static final int abc_spinner_ab_default_holo_dark = 0x7f02003c; public static final int abc_spinner_ab_default_holo_light = 0x7f02003d; public static final int abc_spinner_ab_disabled_holo_dark = 0x7f02003e; public static final int abc_spinner_ab_disabled_holo_light = 0x7f02003f; public static final int abc_spinner_ab_focused_holo_dark = 0x7f020040; public static final int abc_spinner_ab_focused_holo_light = 0x7f020041; public static final int abc_spinner_ab_holo_dark = 0x7f020042; public static final int abc_spinner_ab_holo_light = 0x7f020043; public static final int abc_spinner_ab_pressed_holo_dark = 0x7f020044; public static final int abc_spinner_ab_pressed_holo_light = 0x7f020045; public static final int abc_tab_indicator_ab_holo = 0x7f020046; public static final int abc_tab_selected_focused_holo = 0x7f020047; public static final int abc_tab_selected_holo = 0x7f020048; public static final int abc_tab_selected_pressed_holo = 0x7f020049; public static final int abc_tab_unselected_pressed_holo = 0x7f02004a; public static final int abc_textfield_search_default_holo_dark = 0x7f02004b; public static final int abc_textfield_search_default_holo_light = 0x7f02004c; public static final int abc_textfield_search_right_default_holo_dark = 0x7f02004d; public static final int abc_textfield_search_right_default_holo_light = 0x7f02004e; public static final int abc_textfield_search_right_selected_holo_dark = 0x7f02004f; public static final int abc_textfield_search_right_selected_holo_light = 0x7f020050; public static final int abc_textfield_search_selected_holo_dark = 0x7f020051; public static final int abc_textfield_search_selected_holo_light = 0x7f020052; public static final int abc_textfield_searchview_holo_dark = 0x7f020053; public static final int abc_textfield_searchview_holo_light = 0x7f020054; public static final int abc_textfield_searchview_right_holo_dark = 0x7f020055; public static final int abc_textfield_searchview_right_holo_light = 0x7f020056; } public static final class id { public static final int action_bar = 0x7f070036; public static final int action_bar_activity_content = 0x7f070021; public static final int action_bar_container = 0x7f070035; public static final int action_bar_overlay_layout = 0x7f070039; public static final int action_bar_root = 0x7f070034; public static final int action_bar_subtitle = 0x7f07003d; public static final int action_bar_title = 0x7f07003c; public static final int action_context_bar = 0x7f070037; public static final int action_menu_divider = 0x7f070022; public static final int action_menu_presenter = 0x7f070023; public static final int action_mode_close_button = 0x7f07003e; public static final int activity_chooser_view_content = 0x7f07003f; public static final int always = 0x7f070017; public static final int beginning = 0x7f07001d; public static final int checkbox = 0x7f070047; public static final int collapseActionView = 0x7f070019; public static final int default_activity_button = 0x7f070042; public static final int dialog = 0x7f07001a; public static final int disableHome = 0x7f070014; public static final int dropdown = 0x7f07001b; public static final int edit_query = 0x7f07004a; public static final int end = 0x7f07001f; public static final int expand_activities_button = 0x7f070040; public static final int expanded_menu = 0x7f070046; public static final int home = 0x7f070020; public static final int homeAsUp = 0x7f070011; public static final int icon = 0x7f070044; public static final int ifRoom = 0x7f070016; public static final int image = 0x7f070041; public static final int listMode = 0x7f07000d; public static final int list_item = 0x7f070043; public static final int middle = 0x7f07001e; public static final int never = 0x7f070015; public static final int none = 0x7f07001c; public static final int normal = 0x7f07000c; public static final int progress_circular = 0x7f070024; public static final int progress_horizontal = 0x7f070025; public static final int radio = 0x7f070049; public static final int search_badge = 0x7f07004c; public static final int search_bar = 0x7f07004b; public static final int search_button = 0x7f07004d; public static final int search_close_btn = 0x7f070052; public static final int search_edit_frame = 0x7f07004e; public static final int search_go_btn = 0x7f070054; public static final int search_mag_icon = 0x7f07004f; public static final int search_plate = 0x7f070050; public static final int search_src_text = 0x7f070051; public static final int search_voice_btn = 0x7f070055; public static final int shortcut = 0x7f070048; public static final int showCustom = 0x7f070013; public static final int showHome = 0x7f070010; public static final int showTitle = 0x7f070012; public static final int split_action_bar = 0x7f070038; public static final int submit_area = 0x7f070053; public static final int tabMode = 0x7f07000e; public static final int title = 0x7f070045; public static final int top_action_bar = 0x7f07003a; public static final int up = 0x7f07003b; public static final int useLogo = 0x7f07000f; public static final int withText = 0x7f070018; } public static final class integer { public static final int abc_max_action_buttons = 0x7f0b0000; } public static final class layout { public static final int abc_action_bar_decor = 0x7f030000; public static final int abc_action_bar_decor_include = 0x7f030001; public static final int abc_action_bar_decor_overlay = 0x7f030002; public static final int abc_action_bar_home = 0x7f030003; public static final int abc_action_bar_tab = 0x7f030004; public static final int abc_action_bar_tabbar = 0x7f030005; public static final int abc_action_bar_title_item = 0x7f030006; public static final int abc_action_bar_view_list_nav_layout = 0x7f030007; public static final int abc_action_menu_item_layout = 0x7f030008; public static final int abc_action_menu_layout = 0x7f030009; public static final int abc_action_mode_bar = 0x7f03000a; public static final int abc_action_mode_close_item = 0x7f03000b; public static final int abc_activity_chooser_view = 0x7f03000c; public static final int abc_activity_chooser_view_include = 0x7f03000d; public static final int abc_activity_chooser_view_list_item = 0x7f03000e; public static final int abc_expanded_menu_layout = 0x7f03000f; public static final int abc_list_menu_item_checkbox = 0x7f030010; public static final int abc_list_menu_item_icon = 0x7f030011; public static final int abc_list_menu_item_layout = 0x7f030012; public static final int abc_list_menu_item_radio = 0x7f030013; public static final int abc_popup_menu_item_layout = 0x7f030014; public static final int abc_search_dropdown_item_icons_2line = 0x7f030015; public static final int abc_search_view = 0x7f030016; public static final int abc_simple_decor = 0x7f030017; public static final int support_simple_spinner_dropdown_item = 0x7f0300cc; } public static final class string { public static final int abc_action_bar_home_description = 0x7f080003; public static final int abc_action_bar_up_description = 0x7f080004; public static final int abc_action_menu_overflow_description = 0x7f080005; public static final int abc_action_mode_done = 0x7f080002; public static final int abc_activity_chooser_view_see_all = 0x7f08000c; public static final int abc_activitychooserview_choose_application = 0x7f08000b; public static final int abc_searchview_description_clear = 0x7f080008; public static final int abc_searchview_description_query = 0x7f080007; public static final int abc_searchview_description_search = 0x7f080006; public static final int abc_searchview_description_submit = 0x7f080009; public static final int abc_searchview_description_voice = 0x7f08000a; public static final int abc_shareactionprovider_share_with = 0x7f08000e; public static final int abc_shareactionprovider_share_with_application = 0x7f08000d; } public static final class style { public static final int TextAppearance_AppCompat_Base_CompactMenu_Dialog = 0x7f0c0063; public static final int TextAppearance_AppCompat_Base_SearchResult = 0x7f0c006d; public static final int TextAppearance_AppCompat_Base_SearchResult_Subtitle = 0x7f0c006f; public static final int TextAppearance_AppCompat_Base_SearchResult_Title = 0x7f0c006e; public static final int TextAppearance_AppCompat_Base_Widget_PopupMenu_Large = 0x7f0c0069; public static final int TextAppearance_AppCompat_Base_Widget_PopupMenu_Small = 0x7f0c006a; public static final int TextAppearance_AppCompat_Light_Base_SearchResult = 0x7f0c0070; public static final int TextAppearance_AppCompat_Light_Base_SearchResult_Subtitle = 0x7f0c0072; public static final int TextAppearance_AppCompat_Light_Base_SearchResult_Title = 0x7f0c0071; public static final int TextAppearance_AppCompat_Light_Base_Widget_PopupMenu_Large = 0x7f0c006b; public static final int TextAppearance_AppCompat_Light_Base_Widget_PopupMenu_Small = 0x7f0c006c; public static final int TextAppearance_AppCompat_Light_SearchResult_Subtitle = 0x7f0c0035; public static final int TextAppearance_AppCompat_Light_SearchResult_Title = 0x7f0c0034; public static final int TextAppearance_AppCompat_Light_Widget_PopupMenu_Large = 0x7f0c0030; public static final int TextAppearance_AppCompat_Light_Widget_PopupMenu_Small = 0x7f0c0031; public static final int TextAppearance_AppCompat_SearchResult_Subtitle = 0x7f0c0033; public static final int TextAppearance_AppCompat_SearchResult_Title = 0x7f0c0032; public static final int TextAppearance_AppCompat_Widget_ActionBar_Menu = 0x7f0c001a; public static final int TextAppearance_AppCompat_Widget_ActionBar_Subtitle = 0x7f0c0006; public static final int TextAppearance_AppCompat_Widget_ActionBar_Subtitle_Inverse = 0x7f0c0008; public static final int TextAppearance_AppCompat_Widget_ActionBar_Title = 0x7f0c0005; public static final int TextAppearance_AppCompat_Widget_ActionBar_Title_Inverse = 0x7f0c0007; public static final int TextAppearance_AppCompat_Widget_ActionMode_Subtitle = 0x7f0c001e; public static final int TextAppearance_AppCompat_Widget_ActionMode_Subtitle_Inverse = 0x7f0c0020; public static final int TextAppearance_AppCompat_Widget_ActionMode_Title = 0x7f0c001d; public static final int TextAppearance_AppCompat_Widget_ActionMode_Title_Inverse = 0x7f0c001f; public static final int TextAppearance_AppCompat_Widget_Base_ActionBar_Menu = 0x7f0c0054; public static final int TextAppearance_AppCompat_Widget_Base_ActionBar_Subtitle = 0x7f0c0056; public static final int TextAppearance_AppCompat_Widget_Base_ActionBar_Subtitle_Inverse = 0x7f0c0058; public static final int TextAppearance_AppCompat_Widget_Base_ActionBar_Title = 0x7f0c0055; public static final int TextAppearance_AppCompat_Widget_Base_ActionBar_Title_Inverse = 0x7f0c0057; public static final int TextAppearance_AppCompat_Widget_Base_ActionMode_Subtitle = 0x7f0c0051; public static final int TextAppearance_AppCompat_Widget_Base_ActionMode_Subtitle_Inverse = 0x7f0c0053; public static final int TextAppearance_AppCompat_Widget_Base_ActionMode_Title = 0x7f0c0050; public static final int TextAppearance_AppCompat_Widget_Base_ActionMode_Title_Inverse = 0x7f0c0052; public static final int TextAppearance_AppCompat_Widget_Base_DropDownItem = 0x7f0c0061; public static final int TextAppearance_AppCompat_Widget_DropDownItem = 0x7f0c0021; public static final int TextAppearance_AppCompat_Widget_PopupMenu_Large = 0x7f0c002e; public static final int TextAppearance_AppCompat_Widget_PopupMenu_Small = 0x7f0c002f; public static final int TextAppearance_Widget_AppCompat_Base_ExpandedMenu_Item = 0x7f0c0062; public static final int TextAppearance_Widget_AppCompat_ExpandedMenu_Item = 0x7f0c0028; public static final int Theme_AppCompat = 0x7f0c0077; public static final int Theme_AppCompat_Base_CompactMenu = 0x7f0c0083; public static final int Theme_AppCompat_Base_CompactMenu_Dialog = 0x7f0c0084; public static final int Theme_AppCompat_CompactMenu = 0x7f0c007c; public static final int Theme_AppCompat_CompactMenu_Dialog = 0x7f0c007d; public static final int Theme_AppCompat_DialogWhenLarge = 0x7f0c007a; public static final int Theme_AppCompat_Light = 0x7f0c0078; public static final int Theme_AppCompat_Light_DarkActionBar = 0x7f0c0079; public static final int Theme_AppCompat_Light_DialogWhenLarge = 0x7f0c007b; public static final int Theme_Base = 0x7f0c007e; public static final int Theme_Base_AppCompat = 0x7f0c0080; public static final int Theme_Base_AppCompat_DialogWhenLarge = 0x7f0c0085; public static final int Theme_Base_AppCompat_DialogWhenLarge_Base = 0x7f0c0089; public static final int Theme_Base_AppCompat_Dialog_FixedSize = 0x7f0c0087; public static final int Theme_Base_AppCompat_Dialog_Light_FixedSize = 0x7f0c0088; public static final int Theme_Base_AppCompat_Light = 0x7f0c0081; public static final int Theme_Base_AppCompat_Light_DarkActionBar = 0x7f0c0082; public static final int Theme_Base_AppCompat_Light_DialogWhenLarge = 0x7f0c0086; public static final int Theme_Base_AppCompat_Light_DialogWhenLarge_Base = 0x7f0c008a; public static final int Theme_Base_Light = 0x7f0c007f; public static final int Widget_AppCompat_ActionBar = 0x7f0c0000; public static final int Widget_AppCompat_ActionBar_Solid = 0x7f0c0002; public static final int Widget_AppCompat_ActionBar_TabBar = 0x7f0c0011; public static final int Widget_AppCompat_ActionBar_TabText = 0x7f0c0017; public static final int Widget_AppCompat_ActionBar_TabView = 0x7f0c0014; public static final int Widget_AppCompat_ActionButton = 0x7f0c000b; public static final int Widget_AppCompat_ActionButton_CloseMode = 0x7f0c000d; public static final int Widget_AppCompat_ActionButton_Overflow = 0x7f0c000f; public static final int Widget_AppCompat_ActionMode = 0x7f0c001b; public static final int Widget_AppCompat_ActivityChooserView = 0x7f0c0038; public static final int Widget_AppCompat_AutoCompleteTextView = 0x7f0c0036; public static final int Widget_AppCompat_Base_ActionBar = 0x7f0c003a; public static final int Widget_AppCompat_Base_ActionBar_Solid = 0x7f0c003c; public static final int Widget_AppCompat_Base_ActionBar_TabBar = 0x7f0c0045; public static final int Widget_AppCompat_Base_ActionBar_TabText = 0x7f0c004b; public static final int Widget_AppCompat_Base_ActionBar_TabView = 0x7f0c0048; public static final int Widget_AppCompat_Base_ActionButton = 0x7f0c003f; public static final int Widget_AppCompat_Base_ActionButton_CloseMode = 0x7f0c0041; public static final int Widget_AppCompat_Base_ActionButton_Overflow = 0x7f0c0043; public static final int Widget_AppCompat_Base_ActionMode = 0x7f0c004e; public static final int Widget_AppCompat_Base_ActivityChooserView = 0x7f0c0075; public static final int Widget_AppCompat_Base_AutoCompleteTextView = 0x7f0c0073; public static final int Widget_AppCompat_Base_DropDownItem_Spinner = 0x7f0c005d; public static final int Widget_AppCompat_Base_ListPopupWindow = 0x7f0c0065; public static final int Widget_AppCompat_Base_ListView_DropDown = 0x7f0c005f; public static final int Widget_AppCompat_Base_ListView_Menu = 0x7f0c0064; public static final int Widget_AppCompat_Base_PopupMenu = 0x7f0c0067; public static final int Widget_AppCompat_Base_ProgressBar = 0x7f0c005a; public static final int Widget_AppCompat_Base_ProgressBar_Horizontal = 0x7f0c0059; public static final int Widget_AppCompat_Base_Spinner = 0x7f0c005b; public static final int Widget_AppCompat_DropDownItem_Spinner = 0x7f0c0024; public static final int Widget_AppCompat_Light_ActionBar = 0x7f0c0001; public static final int Widget_AppCompat_Light_ActionBar_Solid = 0x7f0c0003; public static final int Widget_AppCompat_Light_ActionBar_Solid_Inverse = 0x7f0c0004; public static final int Widget_AppCompat_Light_ActionBar_TabBar = 0x7f0c0012; public static final int Widget_AppCompat_Light_ActionBar_TabBar_Inverse = 0x7f0c0013; public static final int Widget_AppCompat_Light_ActionBar_TabText = 0x7f0c0018; public static final int Widget_AppCompat_Light_ActionBar_TabText_Inverse = 0x7f0c0019; public static final int Widget_AppCompat_Light_ActionBar_TabView = 0x7f0c0015; public static final int Widget_AppCompat_Light_ActionBar_TabView_Inverse = 0x7f0c0016; public static final int Widget_AppCompat_Light_ActionButton = 0x7f0c000c; public static final int Widget_AppCompat_Light_ActionButton_CloseMode = 0x7f0c000e; public static final int Widget_AppCompat_Light_ActionButton_Overflow = 0x7f0c0010; public static final int Widget_AppCompat_Light_ActionMode_Inverse = 0x7f0c001c; public static final int Widget_AppCompat_Light_ActivityChooserView = 0x7f0c0039; public static final int Widget_AppCompat_Light_AutoCompleteTextView = 0x7f0c0037; public static final int Widget_AppCompat_Light_Base_ActionBar = 0x7f0c003b; public static final int Widget_AppCompat_Light_Base_ActionBar_Solid = 0x7f0c003d; public static final int Widget_AppCompat_Light_Base_ActionBar_Solid_Inverse = 0x7f0c003e; public static final int Widget_AppCompat_Light_Base_ActionBar_TabBar = 0x7f0c0046; public static final int Widget_AppCompat_Light_Base_ActionBar_TabBar_Inverse = 0x7f0c0047; public static final int Widget_AppCompat_Light_Base_ActionBar_TabText = 0x7f0c004c; public static final int Widget_AppCompat_Light_Base_ActionBar_TabText_Inverse = 0x7f0c004d; public static final int Widget_AppCompat_Light_Base_ActionBar_TabView = 0x7f0c0049; public static final int Widget_AppCompat_Light_Base_ActionBar_TabView_Inverse = 0x7f0c004a; public static final int Widget_AppCompat_Light_Base_ActionButton = 0x7f0c0040; public static final int Widget_AppCompat_Light_Base_ActionButton_CloseMode = 0x7f0c0042; public static final int Widget_AppCompat_Light_Base_ActionButton_Overflow = 0x7f0c0044; public static final int Widget_AppCompat_Light_Base_ActionMode_Inverse = 0x7f0c004f; public static final int Widget_AppCompat_Light_Base_ActivityChooserView = 0x7f0c0076; public static final int Widget_AppCompat_Light_Base_AutoCompleteTextView = 0x7f0c0074; public static final int Widget_AppCompat_Light_Base_DropDownItem_Spinner = 0x7f0c005e; public static final int Widget_AppCompat_Light_Base_ListPopupWindow = 0x7f0c0066; public static final int Widget_AppCompat_Light_Base_ListView_DropDown = 0x7f0c0060; public static final int Widget_AppCompat_Light_Base_PopupMenu = 0x7f0c0068; public static final int Widget_AppCompat_Light_Base_Spinner = 0x7f0c005c; public static final int Widget_AppCompat_Light_DropDownItem_Spinner = 0x7f0c0025; public static final int Widget_AppCompat_Light_ListPopupWindow = 0x7f0c002a; public static final int Widget_AppCompat_Light_ListView_DropDown = 0x7f0c0027; public static final int Widget_AppCompat_Light_PopupMenu = 0x7f0c002c; public static final int Widget_AppCompat_Light_Spinner_DropDown_ActionBar = 0x7f0c0023; public static final int Widget_AppCompat_ListPopupWindow = 0x7f0c0029; public static final int Widget_AppCompat_ListView_DropDown = 0x7f0c0026; public static final int Widget_AppCompat_ListView_Menu = 0x7f0c002d; public static final int Widget_AppCompat_PopupMenu = 0x7f0c002b; public static final int Widget_AppCompat_ProgressBar = 0x7f0c000a; public static final int Widget_AppCompat_ProgressBar_Horizontal = 0x7f0c0009; public static final int Widget_AppCompat_Spinner_DropDown_ActionBar = 0x7f0c0022; } public static final class styleable { public static final int[] ActionBar = { 0x7f010025, 0x7f010026, 0x7f010027, 0x7f010028, 0x7f010029, 0x7f01002a, 0x7f01002b, 0x7f01002c, 0x7f01002d, 0x7f01002e, 0x7f01002f, 0x7f010030, 0x7f010031, 0x7f010032, 0x7f010033, 0x7f010034, 0x7f010035, 0x7f010036, 0x7f010037 }; public static final int[] ActionBarLayout = { 0x010100b3 }; public static final int ActionBarLayout_android_layout_gravity = 0; public static final int[] ActionBarWindow = { 0x7f010000, 0x7f010001, 0x7f010002, 0x7f010003, 0x7f010004, 0x7f010005, 0x7f010006 }; public static final int ActionBarWindow_windowActionBar = 0; public static final int ActionBarWindow_windowActionBarOverlay = 1; public static final int ActionBarWindow_windowFixedHeightMajor = 6; public static final int ActionBarWindow_windowFixedHeightMinor = 4; public static final int ActionBarWindow_windowFixedWidthMajor = 3; public static final int ActionBarWindow_windowFixedWidthMinor = 5; public static final int ActionBarWindow_windowSplitActionBar = 2; public static final int ActionBar_background = 10; public static final int ActionBar_backgroundSplit = 12; public static final int ActionBar_backgroundStacked = 11; public static final int ActionBar_customNavigationLayout = 13; public static final int ActionBar_displayOptions = 3; public static final int ActionBar_divider = 9; public static final int ActionBar_height = 1; public static final int ActionBar_homeLayout = 14; public static final int ActionBar_icon = 7; public static final int ActionBar_indeterminateProgressStyle = 16; public static final int ActionBar_itemPadding = 18; public static final int ActionBar_logo = 8; public static final int ActionBar_navigationMode = 2; public static final int ActionBar_progressBarPadding = 17; public static final int ActionBar_progressBarStyle = 15; public static final int ActionBar_subtitle = 4; public static final int ActionBar_subtitleTextStyle = 6; public static final int ActionBar_title = 0; public static final int ActionBar_titleTextStyle = 5; public static final int[] ActionMenuItemView = { 0x0101013f }; public static final int ActionMenuItemView_android_minWidth = 0; public static final int[] ActionMenuView = { }; public static final int[] ActionMode = { 0x7f010026, 0x7f01002a, 0x7f01002b, 0x7f01002f, 0x7f010031 }; public static final int ActionMode_background = 3; public static final int ActionMode_backgroundSplit = 4; public static final int ActionMode_height = 0; public static final int ActionMode_subtitleTextStyle = 2; public static final int ActionMode_titleTextStyle = 1; public static final int[] ActivityChooserView = { 0x7f01006a, 0x7f01006b }; public static final int ActivityChooserView_expandActivityOverflowButtonDrawable = 1; public static final int ActivityChooserView_initialActivityCount = 0; public static final int[] CompatTextView = { 0x7f01006d }; public static final int CompatTextView_textAllCaps = 0; public static final int[] LinearLayoutICS = { 0x7f01002e, 0x7f010055, 0x7f010056 }; public static final int LinearLayoutICS_divider = 0; public static final int LinearLayoutICS_dividerPadding = 2; public static final int LinearLayoutICS_showDividers = 1; public static final int[] MenuGroup = { 0x0101000e, 0x010100d0, 0x01010194, 0x010101de, 0x010101df, 0x010101e0 }; public static final int MenuGroup_android_checkableBehavior = 5; public static final int MenuGroup_android_enabled = 0; public static final int MenuGroup_android_id = 1; public static final int MenuGroup_android_menuCategory = 3; public static final int MenuGroup_android_orderInCategory = 4; public static final int MenuGroup_android_visible = 2; public static final int[] MenuItem = { 0x01010002, 0x0101000e, 0x010100d0, 0x01010106, 0x01010194, 0x010101de, 0x010101df, 0x010101e1, 0x010101e2, 0x010101e3, 0x010101e4, 0x010101e5, 0x0101026f, 0x7f01004d, 0x7f01004e, 0x7f01004f, 0x7f010050 }; public static final int MenuItem_actionLayout = 14; public static final int MenuItem_actionProviderClass = 16; public static final int MenuItem_actionViewClass = 15; public static final int MenuItem_android_alphabeticShortcut = 9; public static final int MenuItem_android_checkable = 11; public static final int MenuItem_android_checked = 3; public static final int MenuItem_android_enabled = 1; public static final int MenuItem_android_icon = 0; public static final int MenuItem_android_id = 2; public static final int MenuItem_android_menuCategory = 5; public static final int MenuItem_android_numericShortcut = 10; public static final int MenuItem_android_onClick = 12; public static final int MenuItem_android_orderInCategory = 6; public static final int MenuItem_android_title = 7; public static final int MenuItem_android_titleCondensed = 8; public static final int MenuItem_android_visible = 4; public static final int MenuItem_showAsAction = 13; public static final int[] MenuView = { 0x010100ae, 0x0101012c, 0x0101012d, 0x0101012e, 0x0101012f, 0x01010130, 0x01010131, 0x01010438 }; public static final int MenuView_android_headerBackground = 4; public static final int MenuView_android_horizontalDivider = 2; public static final int MenuView_android_itemBackground = 5; public static final int MenuView_android_itemIconDisabledAlpha = 6; public static final int MenuView_android_itemTextAppearance = 1; public static final int MenuView_android_preserveIconSpacing = 7; public static final int MenuView_android_verticalDivider = 3; public static final int MenuView_android_windowAnimationStyle = 0; public static final int[] SearchView = { 0x0101011f, 0x01010220, 0x01010264, 0x7f01005a, 0x7f01005b }; public static final int SearchView_android_imeOptions = 2; public static final int SearchView_android_inputType = 1; public static final int SearchView_android_maxWidth = 0; public static final int SearchView_iconifiedByDefault = 3; public static final int SearchView_queryHint = 4; public static final int[] Spinner = { 0x010100af, 0x01010175, 0x01010176, 0x01010262, 0x010102ac, 0x010102ad, 0x7f010051, 0x7f010052, 0x7f010053, 0x7f010054 }; public static final int Spinner_android_dropDownHorizontalOffset = 4; public static final int Spinner_android_dropDownSelector = 1; public static final int Spinner_android_dropDownVerticalOffset = 5; public static final int Spinner_android_dropDownWidth = 3; public static final int Spinner_android_gravity = 0; public static final int Spinner_android_popupBackground = 2; public static final int Spinner_disableChildrenWhenDisabled = 9; public static final int Spinner_popupPromptView = 8; public static final int Spinner_prompt = 6; public static final int Spinner_spinnerMode = 7; public static final int[] Theme = { 0x7f010047, 0x7f010048, 0x7f010049, 0x7f01004a, 0x7f01004b, 0x7f01004c }; public static final int Theme_actionDropDownStyle = 0; public static final int Theme_dropdownListPreferredItemHeight = 1; public static final int Theme_listChoiceBackgroundIndicator = 5; public static final int Theme_panelMenuListTheme = 4; public static final int Theme_panelMenuListWidth = 3; public static final int Theme_popupMenuStyle = 2; public static final int[] View = { 0x010100da, 0x7f010038, 0x7f010039 }; public static final int View_android_focusable = 0; public static final int View_paddingEnd = 2; public static final int View_paddingStart = 1; } }
facc3c7cfa59d00722caadacdad98b87bd88b7f2
7091134f1825d13f4c6910933d2248528ebd21a8
/dd/src/com/bb/dd/util/PSOCryptography.java
765ceec64211a80e22d07fd2c175ad0e558cad82
[]
no_license
balancejia/balancejiaGit
365c235200de6f34478c4dbb719d5636efc1272c
3473518bb3d88c62e54f0575df08dfbc7252c3a5
refs/heads/master
2021-01-25T12:13:58.361133
2015-04-21T07:02:31
2015-04-21T07:02:31
27,327,756
0
0
null
null
null
null
UTF-8
Java
false
false
6,255
java
package com.bb.dd.util; import java.net.URLDecoder; import java.net.URLEncoder; import java.security.Key; import javax.crypto.Cipher; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.DESedeKeySpec; import javax.crypto.spec.IvParameterSpec; import org.bouncycastle.util.encoders.Base64; import org.bouncycastle.util.encoders.Hex; public class PSOCryptography { private static String CodingType = "UTF-8"; private static String DigestAlgorithm = "SHA1"; private static String CryptAlgorithm = "DESede/CBC/PKCS5Padding"; private static String KeyAlgorithm = "DESede"; private static String strSeparator = "$"; private static byte[] defaultIV = {1,2,3,4,5,6,7,8}; public static String SPID = null; public PSOCryptography() { } static { java.security.Security.addProvider(new com.sun.crypto.provider.SunJCE()); } /** * Function Description Base64���� * @param b ��ҪBase64������ַ����� * @return �������ַ����� * @throws Exception */ public static byte[] Base64Encode(byte[] b) throws Exception { return Base64.encode(b); } /** * Function Description BASE64������ * @param b ��ҪBase64��������ַ����� * @return ���������ַ����� * @throws Exception */ public static byte[] Base64Decode(byte[] b) throws Exception { return Base64.decode(b); } /** * Function Description BASE64������ * @param s ��ҪBase64��������ַ� * @return ���������ַ����� * @throws Exception */ public static byte[] Base64Decode(String s) throws Exception { return Base64.decode(s); } /** * Function Description URL���� * @param strToBeEncode ��ҪURL������ַ� * @return URL�������ַ� * @throws Exception */ public static String URLEncode(String strToBeEncode) throws Exception { return URLEncoder.encode(strToBeEncode); } /** * Function Description URL������ * @param strToBeDecode ��ҪURL��������ַ� * @return URL���������ַ� * @throws Exception */ public static String URLDecode(String strToBeDecode) throws Exception { return URLDecoder.decode(strToBeDecode); } /** * Function Description ���16�����ַ����IV * @param strIV 16�����ַ� * @return �ַ����� * @throws Exception */ public static byte[] IVGenerator(String strIV) throws Exception { return Hex.decode(strIV); } /** * Function Description 3DES���� * @param strTobeEnCrypted Ҫ���ܵ��ַ� * @param strKey ��Կ * @param byteIV ������ * @return ���ܺ���ַ� * @throws Exception */ public static String Encrypt(String strTobeEnCrypted, String strKey, byte[] byteIV) throws Exception { byte[] input = strTobeEnCrypted.getBytes(CodingType); Key k = KeyGenerator(strKey); IvParameterSpec IVSpec = (byteIV.length == 0)?IvGenerator(defaultIV):IvGenerator(byteIV); Cipher c = Cipher.getInstance(CryptAlgorithm); c.init(Cipher.ENCRYPT_MODE,k,IVSpec); byte[] output = c.doFinal(input); return new String(Base64Encode(output),CodingType); } /** * Function Description 3DES���� * @param strTobeDeCrypted Ҫ���ܵ��ַ� * @param strKey ��Կ * @param byteIV ������ * @return ���ܺ���ַ� * @throws Exception */ public static String Decrypt(String strTobeDeCrypted, String strKey, byte[] byteIV) throws Exception { byte[] input = Base64Decode(strTobeDeCrypted); Key k = KeyGenerator(strKey); IvParameterSpec IVSpec = (byteIV.length == 0)?IvGenerator(defaultIV):IvGenerator(byteIV); Cipher c = Cipher.getInstance(CryptAlgorithm); c.init(Cipher.DECRYPT_MODE,k,IVSpec); byte[] output = c.doFinal(input); return new String(output,CodingType); } /*------------------------------------------ * PSOCryptography���ڲ�ʹ�õĹ������� * Modified On: 2003-11-6 * * Modified On: 2005-04-18 * Content: ��ӷ���Hash��Encrypt -----------------------------------------*/ // ˵��: ��ɼӽ����� private static IvParameterSpec IvGenerator(byte[] b) throws Exception { IvParameterSpec IV = new IvParameterSpec(b); return IV; } // ˵��: ���16�����ַ������Կ private static Key KeyGenerator(String KeyStr) throws Exception { byte[] input = Hex.decode(KeyStr); DESedeKeySpec KeySpec = new DESedeKeySpec(input); SecretKeyFactory KeyFactory = SecretKeyFactory.getInstance(KeyAlgorithm); return KeyFactory.generateSecret(KeySpec); } /** * ˵�� ��������ַ����Ƿ����ƶ��ָ��� * ���� String s �����ַ� * char separator �ָ��� * ��� boolean �ǻ�� */ private static boolean hasMoreElement(String s, char separator) { int size = 0; for(int i=0; i<s.length(); i++) { if (s.charAt(i) == separator) size++; } return size>0?true:false; } /** * ˵��: �����ַ�����ij��� * ����: String s - Ҫ���㳤�ȵ��ַ� * ���: int ���� */ private static int length(String[] s) { int length = 0; for(int i=0; i<s.length; i++) { if (s[i] != null) length += s[i].length(); else length += 0; } return length; } }
12ec341cbe8ee79519882ca3aa54d6ea872886b8
6c0b112806ca41258f554be7933eaec922b82652
/Greenfoot/Moshu.java
3b566945a397ff7b71208324989a2bc19b2e4f97
[]
no_license
JasonXian/fight-night
191247686768d55ece0b3bb801dab27be14cbfd0
808cc0dcdc1a982fb5eeb06c8e60970e529930f7
refs/heads/master
2022-06-11T23:58:09.171037
2022-05-18T21:00:50
2022-05-18T21:00:50
96,145,553
0
0
null
null
null
null
UTF-8
Java
false
false
11,857
java
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * same comments as Mario Class * * Adrian Wong Jason Xian * @version (June 15) */ public class Moshu extends Character { GreenfootImage moshu = new GreenfootImage ("moshu.png"); GreenfootImage jump1 = new GreenfootImage ("moshujump1.png"); GreenfootImage jump2 = new GreenfootImage ("moshujump2.png"); GreenfootImage jump3 = new GreenfootImage ("moshujump3.png"); GreenfootImage jump4 = new GreenfootImage ("moshujump4.png"); GreenfootImage jump5 = new GreenfootImage ("moshujump5.png"); GreenfootImage walk1 = new GreenfootImage ("moshuwalk1.png"); GreenfootImage walk2 = new GreenfootImage ("moshuwalk2.png"); GreenfootImage block = new GreenfootImage ("moshublock.png"); GreenfootImage crouch = new GreenfootImage ("moshucrouch.png"); GreenfootImage punch = new GreenfootImage ("moshupunch2.png"); GreenfootImage kick1 = new GreenfootImage ("moshukick1.png"); GreenfootImage kick2 = new GreenfootImage ("moshukick2.png"); GreenfootImage crouchPunch = new GreenfootImage ("moshucrouchpunch2.png"); GreenfootImage crouchKick = new GreenfootImage ("moshucrouchkick.png"); GreenfootImage death1 = new GreenfootImage ("moshudeath1.png"); GreenfootImage death2 = new GreenfootImage ("moshudeath2.png"); GreenfootImage death3 = new GreenfootImage ("moshudeath3.png"); GreenfootImage death4 = new GreenfootImage ("moshudeath4.png"); GreenfootImage victory1 = new GreenfootImage ("moshuvictory1.png"); GreenfootImage victory2 = new GreenfootImage ("moshuvictory2.png"); GreenfootImage victory3 = new GreenfootImage ("moshuvictory3.png"); GreenfootImage moshuFlipped = new GreenfootImage ("moshuflipped.png"); GreenfootImage jump1Flipped = new GreenfootImage ("moshujump1flipped.png"); GreenfootImage jump2Flipped = new GreenfootImage ("moshujump2flipped.png"); GreenfootImage jump3Flipped = new GreenfootImage ("moshujump3flipped.png"); GreenfootImage jump4Flipped = new GreenfootImage ("moshujump4flipped.png"); GreenfootImage jump5Flipped = new GreenfootImage ("moshujump5flipped.png"); GreenfootImage walk1Flipped = new GreenfootImage ("moshuwalk1flipped.png"); GreenfootImage walk2Flipped = new GreenfootImage ("moshuwalk2flipped.png"); GreenfootImage blockFlipped = new GreenfootImage ("moshublockflipped.png"); GreenfootImage crouchFlipped = new GreenfootImage ("moshucrouchflipped.png"); GreenfootImage punchFlipped = new GreenfootImage ("moshupunch2flipped.png"); GreenfootImage kick1Flipped = new GreenfootImage ("moshukick1flipped.png"); GreenfootImage kick2Flipped = new GreenfootImage ("moshukick2flipped.png"); GreenfootImage crouchPunchFlipped = new GreenfootImage ("moshucrouchpunch2flipped.png"); GreenfootImage crouchKickFlipped = new GreenfootImage ("moshucrouchkickflipped.png"); GreenfootImage death1Flipped = new GreenfootImage ("moshudeath1flipped.png"); GreenfootImage death2Flipped = new GreenfootImage ("moshudeath2flipped.png"); GreenfootImage death3Flipped = new GreenfootImage ("moshudeath3flipped.png"); GreenfootImage death4Flipped = new GreenfootImage ("moshudeath4flipped.png"); GreenfootImage victory1Flipped = new GreenfootImage ("moshuvictory1flipped.png"); GreenfootImage victory2Flipped = new GreenfootImage ("moshuvictory2flipped.png"); GreenfootImage victory3Flipped = new GreenfootImage ("moshuvictory3flipped.png"); int jumpCount = 0; int kickCount = 0; int walkCount = 0; int deathCount = 0; int victoryCount = 0; int crouchCount = 0; /** * Act - do whatever the Adobo wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public Moshu(int game){ super(game); } public void act() { if (!(getWorld()instanceof CharacterSelection)){ super.act(); if (super.playerTwoDead){ victoryAnimation(super.flipped()); } if (super.jumped && super.walked && !super.death && !super.playerTwoDead){ walkCount = 0; if (super.flipped() == 0){ setImage(jump5); }else{ setImage (jump5Flipped); } } if (super.jumped && !super.walked && !super.death && !super.playerTwoDead){ jumpAnimation(super.flipped()); } if (super.walked && !super.jumped && !super.death && !super.playerTwoDead){ setY(); crouchCount = 0; walkAnimation(super.flipped()); } if (super.blocked && !super.jumped && !super.death && !super.playerTwoDead){ blockAnimation(super.flipped()); } if (super.kicked && !super.death && !super.playerTwoDead && !super.crouched && !super.walked ){ kickAnimation(super.flipped()); } if (super.punched && !super.death && !super.playerTwoDead && !super.crouched && !super.walked){ punchAnimation(super.flipped()); } if (super.crouched && !super.walked && !super.jumped && !super.death && !super.playerTwoDead && !super.punched && !super.kicked){ crouchAnimation(super.flipped()); } if (super.punched && super.crouched && !super.death && !super.playerTwoDead && !super.walked){ crouchPunch(super.flipped()); } if (super.kicked && super.crouched && !super.death && !super.playerTwoDead && !super.walked){ crouchKick(super.flipped()); } if (super.death && !super.playerTwoDead){ deathAnimation(super.flipped()); } if (!super.jumped && !super.walked && !super.crouched && !super.blocked && !super.punched && !super.kicked && !super.death && !super.playerTwoDead){ jumpCount = 0; kickCount = 0; crouchCount = 0; if (isTouching(Platform.class)){ setY(); } reset(super.flipped()); } } } public void setY(){ setLocation(getX(), 476); } public void reset(int n){ if (n == 0){ setImage (moshu); }else{ setImage (moshuFlipped); } } public void jumpAnimation(int n){ if (n == 0){ if (jumpCount == 0){ setImage(jump1); } if (jumpCount == 3){ setImage(jump2); } if (jumpCount == 6){ setImage(jump3); } if (jumpCount == 8){ setImage(jump4); } if (jumpCount == 12){ setImage(jump5); } jumpCount++; }else { if (jumpCount == 0){ setImage(jump1Flipped); } if (jumpCount == 3){ setImage(jump2Flipped); } if (jumpCount == 6){ setImage(jump3Flipped); } if (jumpCount == 8){ setImage(jump4Flipped); } if (jumpCount == 12){ setImage(jump5Flipped); } jumpCount++; } } public void walkAnimation(int n){ if (n == 0){ if (walkCount == 0){ setImage (walk2); } if (walkCount == 10){ setImage (moshu); } walkCount++; if (walkCount == 20)walkCount = 0; }else{ if (walkCount == 0){ setImage (walk2Flipped); } if (walkCount == 10){ setImage (moshuFlipped); walkCount = 0; } walkCount++; if (walkCount == 10)walkCount = 0; } } public void punchAnimation(int n){ if (n == 0){ setImage(punch); }else{ setImage(punchFlipped); } } public void kickAnimation(int n){ if (n == 0){ if (kickCount == 0){ setImage(kick1); } if (kickCount == 2){ setImage(kick2); } kickCount++; }else{ if (kickCount == 0){ setImage (kick1Flipped); } if(kickCount == 2){ setImage (kick2Flipped); } } } public void blockAnimation(int n){ if (n == 0){ setImage(block); }else{ setImage(blockFlipped); } } public void crouchAnimation(int n){ if (n == 0){ setImage(crouch); if (crouchCount == 0){ setLocation(getX(), getY() + 20); } if (crouchCount <= 2) crouchCount++; }else{ setImage(crouchFlipped); if (crouchCount == 0){ setLocation(getX(), getY() + 20); } if (crouchCount <= 2) crouchCount++; } } public void crouchPunch(int n){ if (n == 0){ setImage(crouchPunch); }else{ setImage(crouchPunchFlipped); } } public void crouchKick(int n){ if (n == 0){ setImage(crouchKick); }else{ setImage(crouchKickFlipped); } } public void deathAnimation(int n){ if (n == 0){ if (deathCount == 0){ setImage (death1); } if (deathCount == 10){ setImage (death2); } if (deathCount == 20){ setImage (death3); } if (deathCount == 30){ setImage (death4); setLocation(getX(), getY()+ 20); } if (deathCount <= 35)deathCount++; }else{ if (deathCount == 0){ setImage (death1Flipped); } if (deathCount == 10){ setImage (death2Flipped); } if (deathCount == 20){ setImage (death3Flipped); } if (deathCount == 30){ setImage (death4Flipped); setLocation(getX(), getY() + 20); } if (deathCount <= 35)deathCount++; } } public void victoryAnimation(int n){ if (n == 0){ if (victoryCount == 5){ setImage (victory1); } if (victoryCount == 10){ setImage (victory2); } if (victoryCount == 15){ setImage (victory3); setLocation(getX(), getY()-10); } if (victoryCount <= 20)victoryCount++; }else{ if (victoryCount == 5){ setImage (victory1Flipped); } if (victoryCount == 10){ setImage (victory2Flipped); } if (victoryCount == 15){ setImage (victory3Flipped); setLocation(getX(), getY()-10); } if (victoryCount <= 10)victoryCount++; } } }
f54aad47c53ab7f9dd366b3c758db19520b78cd2
cc49e2302960153187e99a42baa235776019521e
/03_HelloGit/src/com/kh/git/Test1.java
b5d7557aa9cba9f59455226892ce0853410d1fb7
[]
no_license
heewoon1204/helloGit
3426e4f97e5520db917ff4f9627ddba1858df1e9
090ecacbf25e886ecd6abb4ea4bce1b773f141f4
refs/heads/master
2020-03-19T23:44:37.561581
2018-06-12T04:36:37
2018-06-12T04:36:37
137,017,991
0
0
null
null
null
null
UTF-8
Java
false
false
175
java
package com.kh.git; public class Test1 { public static void main(String[] args) { System.out.println("안녕 깃"); System.out.println("Hello, git"); } }
c249ca3face64f7d88c5fd16cd34130e121224ec
972549525373bddf7e1ba0f391bc954eed6043c4
/app/src/main/java/com/foodaclic/livraison/utils/event/NetworkOperationEvent.java
beb904d12f821e53fe7482db062f3ad2bdb4c24a
[]
no_license
cyrilleguipie/Livraison
d6b1194c15b045cbe952a79e29afc3a690454a8d
9425e70f899820a3f6a6d25ec698fa05cac85171
refs/heads/master
2020-03-22T15:41:19.912462
2018-07-12T09:39:39
2018-07-12T09:39:39
140,269,872
0
0
null
null
null
null
UTF-8
Java
false
false
3,083
java
package com.foodaclic.livraison.utils.event; public class NetworkOperationEvent { final public static int HAS_FAILED = -1; final public static int COST_UPDATED = 100; final public static int HAS_FINISHED_ALL = 10; final public static int HAS_FINISHED_ONE = 1; final public static int HAS_STARTED = 0; final public static int HAS_NOT_SYNCED = 3; final public static int PARAMS = 2; final public static int HAS_CONTACT_SYNC_STARTED = 200; final public static int HAS_NOTHING = 99; final public static int HAS_ROUTE = 90; final public static int HAS_CHANGED = 9000; final public static int HAS_BT_OK = 444; final public static int HAS_BT_NO = 555; private String mMessage; private int mStatus; private long mId; public int mPosition; private boolean isDataFetching; private boolean route; public NetworkOperationEvent(int status) { this.mStatus = status; } //public NetworkOperationEvent(int status, boolean isDataFetching) { // this(status); // this.isDataFetching = isDataFetching; //} /*public NetworkOperationEvent(int status, int position){ this.mStatus=status; this.mPosition=position; }*/ public NetworkOperationEvent(int status, String message) { this(status, true); this.mMessage = message; } public NetworkOperationEvent(int status, long id) { this(status); this.mId = id; } public NetworkOperationEvent(int status, boolean route) { this(status); this.route = route; } public NetworkOperationEvent(int status, String message, boolean isDataFetching) { this(status); this.mMessage = message; } public long getId() { return mId; } public void setId(long mId) { this.mId = mId; } public String getMessage() { return mMessage; } public boolean hasFailed() { return (mStatus == HAS_FAILED); } public boolean hasNothing() { return (mStatus == HAS_NOTHING); } public boolean hasParameters() { return (mStatus == PARAMS); } public boolean isDataFetching() { return isDataFetching; } public void setDataFetching(boolean dataFetching) { isDataFetching = dataFetching; } public boolean hasFinishedAll() { return (mStatus == HAS_FINISHED_ALL); } public boolean hasFinishedOne() { return (mStatus == HAS_FINISHED_ONE); } public boolean hasStarted() { return (mStatus == HAS_STARTED); } public boolean hasContactSyncStarted() { return (mStatus == HAS_CONTACT_SYNC_STARTED); } public boolean hasCostUpdated() { return (mStatus == COST_UPDATED); } public boolean hasNotSynced() { return (mStatus == HAS_NOT_SYNCED); } public void setMessage(String message) { this.mMessage = message; } public boolean isRoute() { return route; } public boolean hasRoute() { return (mStatus == HAS_ROUTE); } public boolean hasChanged() { return (mStatus == HAS_CHANGED); } public boolean hasBTOK() { return (mStatus == HAS_BT_OK); } public boolean hasBTNO() { return (mStatus == HAS_BT_NO); } }
0055469f22a19c199b7747e12798f8bcd7f34617
d41b84a45ef688b14752c0f3b9b07e3955bdbb8a
/android/Whos-Next/mobile/src/main/java/com/wesleyreisz/whos_next/model/Team.java
5c65ced82deb953f9d600ea0fbeb2cd7dfc45f9d
[]
no_license
12019/Android-Wear-Whos-Next
b70314d9ef00bfead52fa946fc57503341e8ff35
ac140333696e3ccad93b5a43b91c2ca35bd43ae7
refs/heads/master
2021-01-12T05:04:32.136017
2015-04-28T00:58:53
2015-04-28T00:58:53
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,744
java
package com.wesleyreisz.whos_next.model; import java.util.List; public class Team{ private String _id; private String helmet; private String hometown; private String logo; private String nickname; private List<Schedule> schedule; private String team; private String warcry; public String get_id(){ return this._id; } public void set_id(String _id){ this._id = _id; } public String getHelmet(){ return this.helmet; } public void setHelmet(String helmet){ this.helmet = helmet; } public String getHometown(){ return this.hometown; } public void setHometown(String hometown){ this.hometown = hometown; } public String getLogo(){ return this.logo; } public void setLogo(String logo){ this.logo = logo; } public String getNickname(){ return this.nickname; } public void setNickname(String nickname){ this.nickname = nickname; } public List<Schedule> getSchedule(){ return this.schedule; } public void setSchedule(List<Schedule> schedule){ this.schedule = schedule; } public String getTeam(){ return this.team; } public void setTeam(String team){ this.team = team; } public String getWarcry(){ return this.warcry; } public void setWarcry(String warcry){ this.warcry = warcry; } @Override public String toString() { return "Team{" + "_id='" + _id + '\'' + ", helmet='" + helmet + '\'' + ", hometown='" + hometown + '\'' + ", logo='" + logo + '\'' + ", nickname='" + nickname + '\'' + ", schedule=" + schedule + ", team='" + team + '\'' + ", warcry='" + warcry + '\'' + '}'; } }
fb8f1bc215aa4d8f1b67c6baf75c01739dcd2c2e
a5d1586973c8edcaddcde50eee732bd0652f4642
/cms-extjs/src/main/java/kr/co/d2net/controller/EquipmentController.java
f8da36050ebf3ba2305ecd3d0178e3f33859e8b9
[]
no_license
inviss/netbro
c0a3a875b0ea98cb7e44864c8944bc003f2fde79
2b266e41f74831724268ca56d3d244d65905c8db
refs/heads/master
2020-07-11T16:04:03.577998
2016-10-03T13:38:35
2016-10-03T13:38:35
74,000,941
0
1
null
null
null
null
UTF-8
Java
false
false
6,631
java
package kr.co.d2net.controller; import java.util.List; import javax.servlet.ServletContext; import kr.co.d2net.dao.TraDao; import kr.co.d2net.dto.EquipmentTbl; import kr.co.d2net.dto.search.Search; import kr.co.d2net.dto.search.SearchControls; import kr.co.d2net.dto.vo.Equip; import kr.co.d2net.exception.ServiceException; import kr.co.d2net.service.AttachServices; import kr.co.d2net.service.AuthServices; import kr.co.d2net.service.CategoryServices; import kr.co.d2net.service.ContentsInstServices; import kr.co.d2net.service.ContentsServices; import kr.co.d2net.service.EquipmentServices; import kr.co.d2net.service.RoleAuthServices; import kr.co.d2net.service.TraServices; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; /** * EquipmentTbl 관련된 업무로직이 구현된 class * @author vayne * */ @Controller public class EquipmentController { final Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private ServletContext servletContext; @Autowired private ContentsServices contentsServices; @Autowired private ContentsInstServices contentsInstServices; @Autowired private EquipmentServices equipmentServices; @Autowired private AuthServices authServices; @Autowired private RoleAuthServices roleAuthServices; @Autowired private CategoryServices categoryServices; @Autowired private AttachServices attachServices; @Autowired private MessageSource messageSource; @Autowired private TraServices traServices; @Autowired private TraDao traDao; /** * 장비 화면 로딩시 필요한 코드값을 불러온다(사용기능 없음.) * @param map * @return */ @RequestMapping(value="/admin/equipment/equipment.ssc", method = RequestMethod.GET) public ModelMap equipment(ModelMap map){ map.addAttribute("search", new Search()); map.addAttribute("equipTbl", new EquipmentTbl()); return map; } /** * Equipment리스트 정보를 가져온다. * @param search * @return */ @RequestMapping(value = "/admin/equipment/findEquipmentList.ssc", method = RequestMethod.GET) public ModelAndView findEquipmentList(@ModelAttribute("search") Search search) { ModelAndView view = new ModelAndView(); Long totalCount = null; try{ if(search.getPageNo() == null){ search.setPageNo(0); } List<Equip> equipmentTbls = equipmentServices.findEquipList(search); totalCount = equipmentServices.count(search); if(totalCount == -1){ view.addObject("result","N"); view.addObject("reason","DB조회중 오류가 발생하였습니다 담당자에게 문의하십시오"); view.setViewName("jsonView"); return view; } view.addObject("search", search); view.addObject("result","Y"); view.addObject("equipmentTbls", equipmentTbls); view.addObject("totalCount",totalCount); view.addObject("pageSize",SearchControls.USER_LIST_COUNT); view.setViewName("jsonView"); return view; } catch (ServiceException e) { view.addObject("result","N"); view.addObject("reason", e.getMessage()); view.setViewName("jsonView"); return view; } } /** * Equipment리스트 정보를 가져온다. * @param search * @return */ @RequestMapping(value = "/admin/equipment/getEquipmentInfo.ssc", method = RequestMethod.GET) public ModelAndView getEquipmentInfo(@ModelAttribute("search") Search search) { ModelAndView view = new ModelAndView(); try{ if (search.getPageNo() == null || search.getPageNo() == 0) { search.setPageNo(1); }else{ search.setPageNo(search.getPageNo()+1); } //List<Equip> equipmentTbl = equipmentServices.getEquipInfo(search); Equip equip = equipmentServices.getEquipInfo(search); view.addObject("search", search); view.addObject("result","Y"); view.addObject("equipmentTbl", equip); view.setViewName("jsonView"); return view; } catch (ServiceException e) { view.addObject("result","N"); view.addObject("reason", e.getMessage()); view.setViewName("jsonView"); return view; } } /** * 장비정보를 save한다. * @param search * @return */ @RequestMapping(value = "/admin/equipment/saveEquipInfo.ssc", method = RequestMethod.POST) public ModelAndView saveEquipInfo(@ModelAttribute("equip")Equip equip) { ModelAndView view = new ModelAndView(); try{ //장비 정보를 저장하는 함수. equipmentServices.saveEquipInfo(equip); view.addObject("result","Y"); view.setViewName("jsonView"); return view; } catch (ServiceException e) { view.addObject("result","N"); view.addObject("reason", e.getMessage()); view.setViewName("jsonView"); return view; } } /** * 장비정보를 save한다. * @param search * @return */ @RequestMapping(value = "/admin/equipment/updateEquipInfo.ssc", method = RequestMethod.POST) public ModelAndView updateEquipInfo(@ModelAttribute("equipTbl")Equip eqTbl) { ModelAndView view = new ModelAndView(); try{ equipmentServices.updateEquipInfo(eqTbl); view.addObject("result","Y"); view.setViewName("jsonView"); return view; } catch (ServiceException e) { view.addObject("result","N"); view.addObject("reason", e.getMessage()); view.setViewName("jsonView"); return view; } } /** * 장비정보의 인스턴스(ex:장비1번 --> 장비1-1번,1-2번,1-3번 이런식으로) * @param eqTbl * @return */ @RequestMapping(value = "/admin/equipment/saveEquipInstance.ssc", method = RequestMethod.POST) public ModelAndView saveEquipInstance(@ModelAttribute("equip")Equip equip) { ModelAndView view = new ModelAndView(); try{ equipmentServices.saveEquipInstance(equip); view.addObject("result","Y"); view.setViewName("jsonView"); return view; } catch (ServiceException e) { view.addObject("result","N"); view.addObject("reason", e.getMessage()); view.setViewName("jsonView"); return view; } } }
[ "mskang0916@4846aee8-341f-0510-a8c2-a716f2a042e0" ]
mskang0916@4846aee8-341f-0510-a8c2-a716f2a042e0
baa66d3b57a9973be8c5061c6b6be745e245b98b
30e2c69e3007ba2e8a54eae66295e785063bc979
/src/main/java/com/demo/challenge/config/RedisConfig.java
6914868fef525a51aa8c90d643af70dfc91a8562
[]
no_license
prashant1982/challenge
83cfbf6de6b0d0f8e77b71156f14774f400b86a7
24d2d2696087c4082361f428e74739cbaeb93818
refs/heads/master
2021-07-14T08:51:46.291551
2017-10-17T09:14:05
2017-10-17T09:14:05
107,241,472
0
0
null
null
null
null
UTF-8
Java
false
false
2,036
java
package com.demo.challenge.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.cache.RedisCacheManager; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import com.demo.challenge.domain.UserSession; /** * Redis configuration class * * @author Prashant * */ @EnableAutoConfiguration @Configuration @EnableCaching public class RedisConfig /*extends CachingConfigurerSupport*/ { @Value("${spring.redis.host}") private String redisHost; @Value("${spring.redis.port}") private int redisPort; @Bean public JedisConnectionFactory redisConnectionFactory() { JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(); jedisConnectionFactory.setHostName(redisHost); jedisConnectionFactory.setPort(redisPort); jedisConnectionFactory.setUsePool(true); return jedisConnectionFactory; } /*@Bean public RedisSerializer redisStringSerializer() { StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); return stringRedisSerializer; }*/ @Bean//(name = "redisTemplate") public RedisTemplate<String, UserSession> redisTemplateUserSession() { RedisTemplate<String, UserSession> redisTemplate = new RedisTemplate<String, UserSession>(); redisTemplate.setConnectionFactory(redisConnectionFactory()); // redisTemplate.setDefaultSerializer(redisSerializer); return redisTemplate; } @Bean public CacheManager cacheManager() { RedisCacheManager cacheManager = new RedisCacheManager(redisTemplateUserSession()); cacheManager.setUsePrefix(true); return cacheManager; } }
82ed972ff9f02787050fff1c4891f735eb3f964f
9603aec554b90f3dd56f6b65b5f9812a1ddb8f58
/01_java/src/ch04_repetition/exam/Quiz15.java
891f7293c8093d5bad090881f5b4ad0cb39767c4
[]
no_license
kimtrue/verita
90700d848ab7d2051f3b89c9a9ba8cbcf1cbc16b
fb85fb54937f5882652b198a5e7454d02d4e2bf9
refs/heads/master
2022-12-14T10:28:25.884166
2019-10-29T11:19:27
2019-10-29T11:19:27
210,785,743
0
0
null
2022-12-04T15:07:08
2019-09-25T07:44:51
HTML
UTF-8
Java
false
false
1,354
java
/** 화면에서 행의 수와 열의 수를 입력 받아 아래와 같은 형식으로 출력되는 프로그램을 작성하시오 주의 사항 : 출력 행이 홀수일 경우 문자( "<" )를 먼저 출력, 짝수일 경우 문자( ">" )를 먼저 출력 출력형식 > 출력할 행의 수를 입력하세요(1-10) : 4 출력할 열의 수를 입력하세요(1-10) : 3 >>> <<< >>> <<< 출력형식 > 출력할 행의 수를 입력하세요(1-10) : 3 출력할 열의 수를 입력하세요(1-10) : 3 <<< >>> <<< */ package ch04_repetition.exam; import java.util.Scanner; public class Quiz15 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("출력할 행의 수를 입력하세요(1-10) : "); int num1 = sc.nextInt(); System.out.print("출력할 열의 수를 입력하세요(1-10) : "); int num2 = sc.nextInt(); // String hol = "<"; // String jjak = ">"; for(int i = 1; i <= num1; i++) { for(int j = 0; j < num2; j++) { if (num1 % 2 == 0) System.out.print(">"); System.out.print("<"); } System.out.println(); } // for(int j = 1; j < num2; j++) // //System.out.print(j); // // { if(j % 2 == 0) { // System.out.printf("%s", jjak); // } // else // System.out.printf("%s",hol); // } } }
3e44b22a24e8a9ce5783aaae94391a4d2e9de450
6aceef303358fd1effd59d8fbd68817f45a84978
/src/main/java/com/ciwise/contacts/web/rest/errors/FieldErrorDTO.java
a8c9028ff48dbdccca6cd445057582694960c821
[]
no_license
ciwise/contacts
ded3bfb94aeba7b47a98bceb01140e82a24674db
9ac72aadd877f99f63294bde81489fa7457c6d89
refs/heads/master
2020-12-31T07:20:42.291276
2016-05-16T05:15:20
2016-05-16T05:15:20
58,841,974
0
0
null
null
null
null
UTF-8
Java
false
false
653
java
package com.ciwise.contacts.web.rest.errors; import java.io.Serializable; public class FieldErrorDTO implements Serializable { private static final long serialVersionUID = 1L; private final String objectName; private final String field; private final String message; public FieldErrorDTO(String dto, String field, String message) { this.objectName = dto; this.field = field; this.message = message; } public String getObjectName() { return objectName; } public String getField() { return field; } public String getMessage() { return message; } }
7407b91a36f44a69da17f892acdec45fa82553dc
6be59179379fd781ef5093b9fb42b0c61151100d
/src/br/com/View/TelaPrincipal.java
c87f30a1e7335e3ca97a91df7f69ebc87d8a18ca
[]
no_license
wagnerlim/APS-interface
5f3b2a044f3e1493c7cf5ce181771b174cd8d33d
14701089cda3b730916fbb87db65d18878ebc19d
refs/heads/master
2023-03-07T12:15:14.983700
2021-02-10T17:48:23
2021-02-10T17:48:23
337,779,027
0
0
null
null
null
null
ISO-8859-1
Java
false
false
12,057
java
package br.com.View; import java.awt.EventQueue; import java.util.List; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import br.com.UsuarioController.AlunosController; import br.com.modelo.Alunos; import javax.swing.JLabel; import javax.swing.JMenuBar; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import java.awt.event.ActionListener; import java.io.IOException; import java.sql.SQLException; import java.awt.event.ActionEvent; import javax.swing.JButton; import javax.swing.JComboBox; import java.awt.Font; import javax.swing.ImageIcon; import java.awt.Color; public class TelaPrincipal extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JPanel contentPane; private DefaultTableModel modelo; private AlunosController AlunosController; private JTable table_1; private JLabel nomeLabel; private JLabel dataNascimentoLabel; private JLabel cursoLabel; private JLabel situacaoLabel; private JMenuItem adicionarAlunoMenuItem; /** * Launch the application. */ public static void main(String[] args) { try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Windows".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { } EventQueue.invokeLater(new Runnable() { public void run() { try { TelaPrincipal frame = new TelaPrincipal(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public TelaPrincipal() { setResizable(false); this.AlunosController = new AlunosController(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 800, 500); // contentPane = new JPanel(); try { // "C:\\Users\\wagne\\Desktop\\Aps interface\\Prancheta 1.png" fundo para teste // "C:\\Users\\wagne\\Desktop\\Aps interface\\FundoTesteAPS.png" Outro fundo para teste contentPane = new FundoBg("C:\\Users\\wagne\\Desktop\\Estudos progamção 2\\APS-Interface\\Imagens\\Fundos de tela\\FundoTesteAPS.png"); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } setContentPane(contentPane); table_1 = new JTable(); table_1.setBounds(10, 218, 764, 169); modelo = (DefaultTableModel) table_1.getModel(); modelo.addColumn("RA"); modelo.addColumn("NOME"); modelo.addColumn("DATA DE NASCIMENTO"); modelo.addColumn("Nome Curso"); modelo.addColumn("Situação"); contentPane.setLayout(null); contentPane.add(table_1); JLabel raLabel = new JLabel("RA"); raLabel.setForeground(Color.BLACK); raLabel.setBounds(10, 204, 46, 14); contentPane.add(raLabel); nomeLabel = new JLabel("Aluno"); nomeLabel.setForeground(Color.BLACK); nomeLabel.setBounds(162, 204, 46, 14); contentPane.add(nomeLabel); dataNascimentoLabel = new JLabel("Data de Nascimento"); dataNascimentoLabel.setForeground(Color.BLACK); dataNascimentoLabel.setBounds(315, 204, 138, 14); contentPane.add(dataNascimentoLabel); cursoLabel = new JLabel("Curso"); cursoLabel.setForeground(Color.BLACK); cursoLabel.setBounds(468, 204, 46, 14); contentPane.add(cursoLabel); situacaoLabel = new JLabel("Situação"); situacaoLabel.setForeground(Color.BLACK); situacaoLabel.setBounds(619, 204, 93, 14); contentPane.add(situacaoLabel); JMenuBar menuBar = new JMenuBar(); menuBar.setBounds(0, 0, 794, 22); contentPane.add(menuBar); JMenu menuAlunos = new JMenu("Alunos"); menuAlunos.setIcon(new ImageIcon("C:\\Users\\wagne\\Desktop\\Estudos progamção 2\\APS-Interface\\Imagens\\icones Tela principal\\study.png")); menuBar.add(menuAlunos); // Item do menu Alunos, Adicionar adicionarAlunoMenuItem = new JMenuItem("Adicionar"); adicionarAlunoMenuItem.setIcon(new ImageIcon("C:\\Users\\wagne\\Desktop\\Estudos progamção 2\\APS-Interface\\Imagens\\icones Tela principal\\plus.png")); menuAlunos.add(adicionarAlunoMenuItem); // Item do menu Alunos, Remover JMenuItem RemoverAlunoMenu = new JMenuItem("Remover"); RemoverAlunoMenu.setIcon(new ImageIcon("C:\\Users\\wagne\\Desktop\\Estudos progamção 2\\APS-Interface\\Imagens\\icones Tela principal\\delete.png")); menuAlunos.add(RemoverAlunoMenu); JMenu mnNewMenu = new JMenu("Usuários"); mnNewMenu.setIcon(new ImageIcon("C:\\Users\\wagne\\Desktop\\Estudos progamção 2\\APS-Interface\\Imagens\\icones Tela principal\\user.png")); menuBar.add(mnNewMenu); JMenuItem AdicionarUsuarioMenuItem = new JMenuItem("Adicionar"); AdicionarUsuarioMenuItem .setIcon(new ImageIcon("C:\\Users\\wagne\\Desktop\\Estudos progamção 2\\APS-Interface\\Imagens\\icones Tela principal\\userAdicionar.png")); mnNewMenu.add(AdicionarUsuarioMenuItem); JMenuItem removerUsuarioItem = new JMenuItem("Remover"); removerUsuarioItem .setIcon(new ImageIcon("C:\\Users\\wagne\\Desktop\\Estudos progamção 2\\APS-Interface\\Imagens\\icones Tela principal\\userRemover.png")); mnNewMenu.add(removerUsuarioItem); JMenuItem mntmNewMenuItem = new JMenuItem("Log off"); mntmNewMenuItem.setIcon(new ImageIcon("C:\\Users\\wagne\\Desktop\\Estudos progamção 2\\APS-Interface\\Imagens\\icones Tela principal\\Log off.png")); mnNewMenu.add(mntmNewMenuItem); // Botão de atualizar a tabela JButton btnNewButton = new JButton("Atualizar"); btnNewButton.setIcon(new ImageIcon("C:\\Users\\wagne\\Desktop\\Estudos progamção 2\\APS-Interface\\Imagens\\icones Tela principal\\botao-atualizar.png")); btnNewButton.setBounds(637, 170, 115, 23); contentPane.add(btnNewButton); // Caixa de cursos JComboBox<String> cursoCombox = new JComboBox<String>(); cursoCombox.setBounds(23, 157, 138, 22); contentPane.add(cursoCombox); cursoCombox.addItem("Curso"); List<String> cursos = this.cursosListar(); for (String string : cursos) { cursoCombox.addItem(string); } // Caixa de Seleção de Situações da matricula JComboBox<String> SituacaoCombox = new JComboBox<String>(); SituacaoCombox.setBounds(184, 157, 138, 22); contentPane.add(SituacaoCombox); SituacaoCombox.addItem("Selecione"); List<String> Situacao = this.SituacaoListar(); for (String string : Situacao) { SituacaoCombox.addItem(string); } // Botão Alterar JButton AlterarBotao = new JButton("Alterar"); AlterarBotao.setBounds(10, 422, 89, 23); contentPane.add(AlterarBotao); JLabel cursosLabel = new JLabel("Cursos"); cursosLabel.setForeground(Color.BLACK); cursosLabel.setFont(new Font("Tahoma", Font.PLAIN, 14)); cursosLabel.setBounds(23, 143, 46, 14); contentPane.add(cursosLabel); JLabel matriculaLabel = new JLabel("Status"); matriculaLabel.setForeground(Color.BLACK); matriculaLabel.setFont(new Font("Tahoma", Font.PLAIN, 14)); matriculaLabel.setBounds(184, 143, 135, 14); contentPane.add(matriculaLabel); // Evento que acontece quando clica no botão Atualizar btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { limparTabela(); preencherTabelaComCurso(); } }); preencherTabelaComCurso(); // Evento que acontece quando clica no item Adicionar do menu alunos adicionarAlunoMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AdicionarAlunoFrame novaView = new AdicionarAlunoFrame(); novaView.setVisible(true); novaView.setLocationRelativeTo(null); } }); // Evento que acontece quando clica no item remover do menu alunos RemoverAlunoMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RemoverAlunoFrame novaView = new RemoverAlunoFrame(); novaView.setVisible(true); novaView.setLocationRelativeTo(null); } }); // Evento que acontece quando clica no item Adicionar do menu Usuarios AdicionarUsuarioMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AdicionarUsuarioFrame novaView = new AdicionarUsuarioFrame(); novaView.setVisible(true); novaView.setLocationRelativeTo(null); } }); // Evento que acontece quando clica no item Remover menu do Usuarios removerUsuarioItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { RemoverUsuarioFrame novaView = new RemoverUsuarioFrame(); novaView.setVisible(true); novaView.setLocationRelativeTo(null); } }); // Evento que acontece quando clica no botão alterar AlterarBotao.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (cursoCombox.getSelectedItem().equals("Curso") == true) { JOptionPane.showMessageDialog(null, "Selecione um curso", "Nenhum curso Selecionado", JOptionPane.ERROR_MESSAGE); } else if (SituacaoCombox.getSelectedItem().equals("Selecione") == true) { JOptionPane.showMessageDialog(null, "Selecione um status da matricula", "Nenhum Status da matricula foi selecionado", JOptionPane.ERROR_MESSAGE); } else { try { alterar(converterCursoEmInt(String.valueOf(cursoCombox.getSelectedItem())), converterSituacaoEmInt(String.valueOf(SituacaoCombox.getSelectedItem()))); JOptionPane.showMessageDialog(null, "Alterações aplicadas!", "Alterações feitas", JOptionPane.INFORMATION_MESSAGE); // limparTabela(); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }); //Evento do botão log off mntmNewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); NovaTelaLogin novaTelaLogin = new NovaTelaLogin(); novaTelaLogin.setVisible(true); } }); } // METODOS DA VIEW public void preencherTabela() { List<Alunos> alunos = ListarAlunos(); try { for (Alunos aluno : alunos) { modelo.addRow(new Object[] { aluno.getRA(), aluno.getNome(), aluno.getDataNascimento() }); } } catch (Exception e) { throw e; } } private void limparTabela() { int UltimaTabela = modelo.getRowCount() - 1; System.out.println(UltimaTabela); modelo.removeRow(UltimaTabela); modelo.getDataVector().clear(); } private void preencherTabelaComCurso() { List<Alunos> alunos = ListarAlunosComCurso(); try { for (Alunos aluno : alunos) { modelo.addRow(new Object[] { aluno.getRA(), aluno.getNome(), aluno.getDataNascimento(), aluno.getCursonome(), aluno.getSituacaoNome() }); } } catch (Exception e) { throw e; } } private List<Alunos> ListarAlunos() { return this.AlunosController.listar(); } private List<Alunos> ListarAlunosComCurso() { return this.AlunosController.listarComCurso(); } private List<String> cursosListar() { return AlunosController.listarCursos(); } private List<String> SituacaoListar() { return AlunosController.listarSituacao(); } public int converterCursoEmInt(String CursoNome) throws SQLException { return this.AlunosController.ConversorCursoNomeId(CursoNome); } public int converterSituacaoEmInt(String Situacaonome) throws SQLException { return this.AlunosController.ConversosSituacaoId(Situacaonome); } private void alterar(int Cursoid, int Situacaoid) { Object objetoDaLinha = (Object) modelo.getValueAt(table_1.getSelectedRow(), table_1.getSelectedColumn()); if (objetoDaLinha instanceof String) { String ra = (String) objetoDaLinha; String nome = (String) modelo.getValueAt(table_1.getSelectedRow(), 1); String data_nascimento = (String) modelo.getValueAt(table_1.getSelectedRow(), 2); this.AlunosController.Alterar(nome, data_nascimento, Cursoid, Situacaoid, ra); } else { JOptionPane.showMessageDialog(this, "Por favor, selecionar o RA"); } } }
1b7d747815fece3da899ecc156ab70263efd3078
2781b87f0c4b63a1f9005e58b62e4a84d4fc2b66
/src/com/ryanworks/fishery/server/dao/DaoFactory.java
fa4b730e313a816658fd20a280355555642f66be
[]
no_license
ryankschee/fishery
ae5294083754401466d74e48bf183d16bf13c712
44e45d7568b0ce3d891b07672ac9c045fec36c56
refs/heads/master
2021-07-04T16:27:29.449384
2020-01-01T03:38:59
2020-01-01T03:38:59
231,076,668
0
0
null
2021-04-26T19:50:32
2019-12-31T11:16:27
TSQL
UTF-8
Java
false
false
5,644
java
package com.ryanworks.fishery.server.dao; import com.ryanworks.fishery.server.dao.impl.*; import com.ryanworks.fishery.shared.util.MyLogger; import java.util.Collections; import java.util.HashMap; import java.util.Map; public abstract class DaoFactory { public static final int MYSQL = 1; static Map cachedDAO; public static DaoFactory getDAOFactory(int whichFactory) { switch (whichFactory) { case MYSQL: return new MySQLDaoFactory(); default: return null; } } protected Object createDAO(Class classObj) throws DaoException { // Check if pool of DAO is available if (cachedDAO == null) { cachedDAO = Collections.synchronizedMap(new HashMap()); } // Check if pool contain the respective DAO object, if YES, then reuse Object daoObj = cachedDAO.get(classObj.getName()); if (daoObj != null) { return daoObj; } // No cached DAO object, so create a new one and insert it into pool of // cache for reuse purpose. try { daoObj = classObj.newInstance(); cachedDAO.put(classObj.getName(), daoObj); return daoObj; } catch (InstantiationException e) { MyLogger.logError(getClass(), "exception: " + e.getMessage()); throw new DaoException(e); } catch (IllegalAccessException e) { MyLogger.logError(getClass(), "exception: " + e.getMessage()); throw new DaoException(e); } finally { return daoObj; } } public MySQLUserDaoImpl getUserDao() throws DaoException { return (MySQLUserDaoImpl) createDAO(MySQLUserDaoImpl.class); } public MySQLCustomerDaoImpl getCustomerDao() throws DaoException { return (MySQLCustomerDaoImpl) createDAO(MySQLCustomerDaoImpl.class); } public MySQLCustomerPaymentDaoImpl getCustomerPaymentDao() throws DaoException { return (MySQLCustomerPaymentDaoImpl) createDAO(MySQLCustomerPaymentDaoImpl.class); } public MySQLCustomerSummaryDaoImpl getCustomerSummaryDao() throws DaoException { return (MySQLCustomerSummaryDaoImpl) createDAO(MySQLCustomerSummaryDaoImpl.class); } public MySQLCategoryDaoImpl getCategoryDao() throws DaoException { return (MySQLCategoryDaoImpl) createDAO(MySQLCategoryDaoImpl.class); } public MySQLItemDaoImpl getItemDao() throws DaoException { return (MySQLItemDaoImpl) createDAO(MySQLItemDaoImpl.class); } public MySQLSupplierDaoImpl getSupplierDao() throws DaoException { return (MySQLSupplierDaoImpl) createDAO(MySQLSupplierDaoImpl.class); } public MySQLSupplierChequeDaoImpl getSupplierChequeDao() throws DaoException { return (MySQLSupplierChequeDaoImpl) createDAO(MySQLSupplierChequeDaoImpl.class); } public MySQLSupplierFuelDaoImpl getSupplierFuelDao() throws DaoException { return (MySQLSupplierFuelDaoImpl) createDAO(MySQLSupplierFuelDaoImpl.class); } public MySQLSupplierMiscDaoImpl getSupplierMiscDao() throws DaoException { return (MySQLSupplierMiscDaoImpl) createDAO(MySQLSupplierMiscDaoImpl.class); } public MySQLSupplierCashDaoImpl getSupplierCashDao() throws DaoException { return (MySQLSupplierCashDaoImpl) createDAO(MySQLSupplierCashDaoImpl.class); } public MySQLSupplierWithdrawalDaoImpl getSupplierWithdrawalDao() throws DaoException { return (MySQLSupplierWithdrawalDaoImpl) createDAO(MySQLSupplierWithdrawalDaoImpl.class); } public MySQLInTransactionDaoImpl getInTransactionDao() throws DaoException { return (MySQLInTransactionDaoImpl) createDAO(MySQLInTransactionDaoImpl.class); } public MySQLInTransactionLineDaoImpl getInTransactionLineDao() throws DaoException { return (MySQLInTransactionLineDaoImpl) createDAO(MySQLInTransactionLineDaoImpl.class); } public MySQLSalesDaoImpl getSalesDao() throws DaoException { return (MySQLSalesDaoImpl) createDAO(MySQLSalesDaoImpl.class); } public MySQLSalesLineDaoImpl getSalesLineDao() throws DaoException { return (MySQLSalesLineDaoImpl) createDAO(MySQLSalesLineDaoImpl.class); } public MySQLSalesBucketDaoImpl getSalesBucketDao() throws DaoException { return (MySQLSalesBucketDaoImpl) createDAO(MySQLSalesBucketDaoImpl.class); } public MySQLSupplierSummaryDaoImpl getSupplierSummaryDao() throws DaoException { return (MySQLSupplierSummaryDaoImpl) createDAO(MySQLSupplierSummaryDaoImpl.class); } public MySQLSupplierSummarySavingDaoImpl getSupplierSummarySavingDao() throws DaoException { return (MySQLSupplierSummarySavingDaoImpl) createDAO(MySQLSupplierSummarySavingDaoImpl.class); } public MySQLSystemDaoImpl getSystemDao() throws DaoException { return (MySQLSystemDaoImpl) createDAO(MySQLSystemDaoImpl.class); } }
ecf18f9c2fcd94c51d03c95e31ee4ba5962ee1c3
aa10edf2189da5e9918d672da7800458dc2cb816
/HackerRank/src/interviewkit/warmup/SockMerchant.java
475d5cec2c6a97d9052f19a9e66ff82976ea8fcd
[]
no_license
Hemalatha09/Coding
28e9247fa767d47e663700230c7e474e526ab1eb
5296e17445618cdf7184ec2417de2b4a42dc7a68
refs/heads/master
2020-08-09T12:36:14.638441
2019-10-09T16:39:27
2019-10-09T16:39:27
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,827
java
package interviewkit.warmup; import java.util.*; public class SockMerchant { // Complete the sockMerchant function below. static int sockMerchant(int n, int[] ar) { Set<Integer> sockMap = new HashSet<>(); int pairs = 0; for (int i=0;i <n; i++){ if (sockMap.contains(ar[i])) { pairs++; sockMap.remove(ar[i]); } else { sockMap.add(ar[i]); } } return pairs; } public static void sockMerchant(String[] args) { int n = 9; int[] ar = {10,20,20,10,10,30,50,10,20}; int result = sockMerchant(n, ar); System.out.println(result); } } /* John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. For example, there are socks with colors . There is one pair of color and one of color . There are three odd socks left, one of each color. The number of pairs is . Function Description Complete the sockMerchant function in the editor below. It must return an integer representing the number of matching pairs of socks that are available. sockMerchant has the following parameter(s): n: the number of socks in the pile ar: the colors of each sock Input Format The first line contains an integer , the number of socks represented in . The second line contains space-separated integers describing the colors of the socks in the pile. Constraints where Output Format Return the total number of matching pairs of socks that John can sell. Sample Input 9 10 20 20 10 10 30 50 10 20 Sample Output 3 Explanation sock.png John can match three pairs of socks. */
a5f8efeac7c9f8ccf9799ef1867c0fba0097ddda
edb4528f327fb0656a10c673372a5bae3daeb236
/MavenProject/src/test/java/com/picnic/maven/MultipleWindowHandle.java
7f96ca8853dc9751837235ffa5d9610a5c214424
[]
no_license
Gopalakrishnanjm/firstdemo
630d532d9aaf486343e9b0a5457b6cf2cf7c6269
9d6507a1999071df2817385e857c75060970c58b
refs/heads/master
2023-08-07T12:17:30.238719
2021-09-20T07:08:15
2021-09-20T07:08:15
407,403,044
0
0
null
null
null
null
UTF-8
Java
false
false
2,013
java
package com.picnic.maven; import java.util.Iterator; import java.util.Set; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class MultipleWindowHandle { public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "C:\\Users\\gopalakrishnanjm\\eclipse-workspace-seleniumTraining\\SeleniumProject\\drivers\\chromedriver.exe"); WebDriver driver=new ChromeDriver(); //Launching the site. driver.get("http://demo.guru99.com/popup.php"); driver.manage().window().maximize(); driver.findElement(By.xpath("//*[contains(@href,'popup.php')]")).click(); String MainWindow=driver.getWindowHandle(); // To handle all new opened window. Set<String> s1=driver.getWindowHandles(); Iterator<String> i1=s1.iterator(); while(i1.hasNext()) { String ChildWindow=i1.next(); if(!MainWindow.equalsIgnoreCase(ChildWindow)) { Thread.sleep(3000); // Switching to Child window driver.switchTo().window(ChildWindow); driver.findElement(By.name("emailid")) .sendKeys("[email protected]"); driver.findElement(By.name("btnLogin")).click(); // Closing the Child Window. driver.close(); } } // Switching to Parent window i.e Main Window. driver.switchTo().window(MainWindow); } }
5bca6dcd4a814d19bf41fc6b951533af4f6e2f31
4f6ab6ed5008988d9127b2794bc8cf659664774e
/hadoop/src/main/java/FullText_DocLen.java
25ed520913e7844df491151fb055b01a4b239ea6
[]
no_license
pariirap/javastuff
4b3ddfbb5cf4666a9d7726cb94794eccea1a14ba
37cb19fc3ebd8e269641501141c8211687194531
refs/heads/master
2021-01-17T15:20:36.551137
2017-07-16T20:05:59
2017-07-16T20:05:59
84,107,222
0
0
null
null
null
null
UTF-8
Java
false
false
2,845
java
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; import org.apache.hadoop.filecache.DistributedCache; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Mapper.Context; public class FullText_DocLen { public static class DocLen_Mapper extends Mapper<LongWritable, /* Input key Type */ Text, /* Input value Type */ Text, /* Output key Type */ IntWritable> /* Output value Type */ { Set<String> stopWords; public static final String HDFS_STOPWORD_LIST = "/users/PariRajaram/local/stop_words.txt"; public static final String LOCAL_STOPWORD_LIST = "/Users/PariRajaram/stopwords.txt"; protected void setup(Context context) throws IOException, InterruptedException { try { String stopwordCacheName = new Path(HDFS_STOPWORD_LIST).getName(); Path[] cacheFiles = DistributedCache.getLocalCacheFiles(context.getConfiguration()); if (null != cacheFiles && cacheFiles.length > 0) { for (Path cachePath : cacheFiles) { if (cachePath.getName().equals(stopwordCacheName)) { loadStopWords(cachePath); break; } } } } catch (IOException ioe) { System.err.println("IOException reading from distributed cache"); System.err.println(ioe.toString()); } } void loadStopWords(Path cachePath) throws IOException { // note use of regular java.io methods here - this is a local file // now BufferedReader wordReader = new BufferedReader(new FileReader(cachePath.toString())); try { String line; System.out.println("stopword init"); stopWords = new HashSet<String>(); while ((line = wordReader.readLine()) != null) { stopWords.add(line); } } finally { wordReader.close(); } } // Map function public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { int fieldLen = 0; // static Map<String, Integer> wordMap = new HashMap(); // reporter.incrCounter(RecordCounters.DOCLEN, 1); String line = value.toString(); // StringTokenizer strToken = new StringTokenizer(line, " , "); // String token; // String docId = strToken.nextToken(); int count=0; while (strToken.hasMoreTokens()) { token = strToken.nextToken(); StringTokenizer strToken2 = new StringTokenizer(token, "\";/ -\'"); while (strToken2.hasMoreTokens()) { String word = strToken2.nextToken(); if (!stopWords.contains(word)) { count++; } } } context.write(new Text(docId), new IntWritable(count)); } } }
c55740c1d221aca7164d94a84c58a4aa4a21f762
708148e391d38875da09716fd6062c0059e164f9
/GuruxXML2PDU/gurux.dlms.java/development/src/main/java/gurux/dlms/objects/GXDLMSModemInitialisation.java
571667383adaf499979d107f6ca87f0041f9d7e4
[]
no_license
BlockWorksCo/Playground
87bf2cdadbc33f020e5d8fb7f3ff875f054ad77d
c968e22cd923ee184fe9362905a4d58e9f69cb27
refs/heads/master
2021-01-23T14:39:05.530058
2020-05-13T22:21:54
2020-05-13T22:21:54
22,513,247
1
0
null
2021-01-04T22:59:52
2014-08-01T14:25:57
C
UTF-8
Java
false
false
1,900
java
// // -------------------------------------------------------------------------- // Gurux Ltd // // // // Filename: $HeadURL$ // // Version: $Revision$, // $Date$ // $Author$ // // Copyright (c) Gurux Ltd // //--------------------------------------------------------------------------- // // DESCRIPTION // // This file is a part of Gurux Device Framework. // // Gurux Device Framework is Open Source 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; version 2 of the License. // Gurux Device Framework 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. // // More information of Gurux products: http://www.gurux.org // // This code is licensed under the GNU General Public License v2. // Full text may be retrieved at http://www.gnu.org/licenses/gpl-2.0.txt //--------------------------------------------------------------------------- package gurux.dlms.objects; public class GXDLMSModemInitialisation { private String request; private String response; private int delay; public final String getRequest() { return request; } public final void setRequest(final String value) { request = value; } public final String getResponse() { return response; } public final void setResponse(final String value) { response = value; } public final int getDelay() { return delay; } public final void setDelay(final int value) { delay = value; } @Override public final String toString() { return request + " " + response + " " + delay; } }
5a1ac5cf01fe4df0c37f2d4522acf9fa9441c7fb
723679b44280cbd73108e89a8100397971f8f09d
/src/main/java/com/codesignal/csbot/listeners/BotCommand.java
5581fa4a722c0b44c52440d62aecd778971ed428
[]
no_license
baodvu/csbot
f69466d0d628c2f0a4529bbae94b6016664aefa6
a36305f17b924b5b4cbe66cac057beb165f9ecf3
refs/heads/main
2021-07-03T07:54:04.732196
2020-11-10T17:13:10
2020-11-10T17:13:10
193,787,395
0
0
null
null
null
null
UTF-8
Java
false
false
779
java
package com.codesignal.csbot.listeners; public class BotCommand { private String rawCommandName; private String commandName; private String commandParams; public String getRawCommandName() { return rawCommandName; } BotCommand withRawCommandName(String rawCommandName) { this.rawCommandName = rawCommandName; return this; } public String getCommandName() { return commandName; } BotCommand withCommandName(String commandName) { this.commandName = commandName; return this; } public String getCommandParams() { return commandParams; } BotCommand withCommandParams(String commandParams) { this.commandParams = commandParams; return this; } }
[ "Inc6WJR1pd2h" ]
Inc6WJR1pd2h
a7d77cc7dc7304195e88787874f6ee2bec9f7343
ecf4cf6f0e3cda94851b228742b6877fc8b02254
/backend/Assignment3_Backend/src/main/java/com/assignment1/Assignment3_Backend/dto/builder/MedicationListBuilder.java
984860a9e6c8e3b8c6fc895a733d1c2918f953e9
[]
no_license
Ioniqe/Online-Medication-Platform
c205359bb31468f130cfcda6fa2066434858a3c4
674bdd3ae91b9762526b6f0549fa3a36f01a191c
refs/heads/master
2023-04-19T20:33:04.035307
2021-05-09T20:40:37
2021-05-09T20:40:37
365,830,659
0
0
null
null
null
null
UTF-8
Java
false
false
883
java
package com.assignment1.DS2020_30441_Bozdog_Ioana_Assignment_3.dto.builder; import com.assignment1.DS2020_30441_Bozdog_Ioana_Assignment_3.dto.MedicationListDTO; import com.assignment1.DS2020_30441_Bozdog_Ioana_Assignment_3.entity.MedicationList; import com.assignment1.DS2020_30441_Bozdog_Ioana_Assignment_3.entity.MedicationPlan; public class MedicationListBuilder { public MedicationListBuilder() { } public static MedicationListDTO toMedicationListDTO(MedicationList medicationList){ return new MedicationListDTO(medicationList.getId(), medicationList.getStartInterval(), medicationList.getEndInterval()); } public static MedicationList toEntity(MedicationListDTO medicationListDTO, MedicationPlan medicationPlan){ return new MedicationList(medicationListDTO.getStartInterval(), medicationListDTO.getEndInterval(), medicationPlan); } }
6feeac085ae07179af6f2af173d1d1db23bb31f0
a1a15238fc09c8b19504deb6d2610d3d315e7430
/SequenceEquation.java
fb19c90fd9fd6f1bd8e48c60b4765a92f50a702a
[]
no_license
Mrd278/Codeforces_Java
d84b53e1afe66dd468cb4b878be31e8e8c779e65
b0984f2b74e3a1c75d7de3ef0b33c86dc39e8d91
refs/heads/master
2020-12-27T15:45:13.641177
2020-07-15T10:19:34
2020-07-15T10:19:34
237,956,866
2
0
null
null
null
null
UTF-8
Java
false
false
1,238
java
import java.util.Arrays; import java.util.Scanner; public class SequenceEquation { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] p = new int[n]; for(int i = 0; i < n; i++) p[i] = sc.nextInt(); int[] result = solve(p); for(int value:result) System.out.println(value); //System.out.print(Arrays.binarySearch(p, 4)); sc.close(); } public static int findIndex(int arr[], int t) { // if array is Null if (arr == null) { return -1; } // find length of array int len = arr.length; int i = 0; // traverse in the array while (i < len) { // if the i-th element is t // then return the index if (arr[i] == t) { return i; } else { i = i + 1; } } return -1; } public static int[] solve(int[] p) { int[] res = new int[p.length]; for(int i = 0; i < p.length; i++) res[i] = findIndex(p, findIndex(p, i+1) + 1) + 1; return res; } }
434738889287bd8c7046ff6b9b4e414b14794181
19a7d4f2ed3122464a50165612803ee088880346
/Prueba/Ejercicio_Operadores.java
74571076dc2d2216d16e852485eee04b0fdc146a
[]
no_license
JoseRicardoJimenez/Java_Exercise
06a1969c3af4f0e46da0bf850488dedf0b13aaa8
770f5e642acbf2379f9ec84fb2cb9869149c3c44
refs/heads/master
2023-05-13T22:28:29.354674
2021-05-28T04:45:19
2021-05-28T04:45:19
69,976,417
0
0
null
null
null
null
UTF-8
Java
false
false
3,975
java
package Prueba; import java.util.Scanner; public class Ejercicio_Operadores { Scanner ing = new Scanner(System.in); public float Ejercicio_2() { //Salario semanal de un empleado int Htrabajadas; float Shora, Stotal; System.out.println("Horas trabajadas por el empleado: "); Htrabajadas = ing.nextInt(); System.out.println("Salario por hora del trabajador: "); Shora = ing.nextFloat(); Stotal = Htrabajadas * Shora; System.out.println("El salario total del empleado es de: " + Stotal); return 0; } public int Ejercicio_3() { //Averiguar la cantidad de dinero float guillermo, luis, juan, tres; System.out.println("Ingresar Dinero de Guillermo"); guillermo = ing.nextFloat(); luis = guillermo / 2; juan = (luis + guillermo) / 2; tres = luis + guillermo + juan; System.out.println("Guillermo tiene: " + guillermo + " Luis tiene: " + luis + " Juan tiene: " + juan + " Total: " + tres); return 0; } public double Ejercicio_4(){ //Salario mensual de un vendedor final int Smensual=1000; int Avendidos,Vauto; double Comision,Stotal; System.out.println("Autos vendidos: "); Avendidos = ing.nextInt(); Comision = 150*Avendidos; for(int x=0; x<Avendidos; x++){ System.out.println("Valor del auto "+x+1+": "); Vauto=ing.nextInt(); Comision = Comision+(Vauto*.05); } Stotal=Smensual+Comision; System.out.println("El salario total es de: "+Stotal); return 0; } public int Ejercicio_5(){ //Calificacion final de un estudiante double Participacion, Eparcial1, Eparcial2, Efinal, Cfinal; System.out.println("Participacion: "); Participacion=ing.nextDouble(); System.out.println("Examen Parcial 1: "); Eparcial1=ing.nextDouble(); System.out.println("Examen parcial 2: "); Eparcial2=ing.nextDouble(); System.out.println("Examen final: "); Efinal=ing.nextDouble(); Participacion = Participacion*.10; Eparcial1 = Eparcial1*.25; Eparcial2 = Eparcial2*.25; Efinal = Efinal*.40; Cfinal = Participacion+Eparcial1+Eparcial2+Efinal; System.out.println("La calificacion final del estudiante es: "+Cfinal); return 0; } public int Ejercicio_6(){ double a, b, resultado; System.out.println("Ingrese el valor de a: "); a=ing.nextDouble(); System.out.println("Ingrese el valor de b: "); b=ing.nextDouble(); resultado = Math.pow(a, 2) + Math.pow(b, 2) + (2*a*b); System.out.println("El resultado es: "+resultado); return 0; } public int Ejercicio_7(){ int Thoras,Semana,dia,hora; System.out.println("Ingrese una cantidad de horas: "); Thoras = ing.nextInt(); Semana=Thoras/168; dia = Thoras%168/24; hora = Thoras%24; System.out.println("Semanas: "+Semana+" Días: "+dia+" Horas: "+hora); return 0; } public int Ejercicio_8(){ double a,b,c,resultado1,resultado2; System.out.println("Dame el valor de a: "); a = ing.nextDouble(); System.out.println("Dame el valor de b: "); b = ing.nextDouble(); System.out.println("Dame el valor de c: "); c = ing.nextDouble(); resultado1 = (-b+Math.sqrt(Math.pow(b, 2) - (4*a*c)))/(2*a); resultado2 = (-b-Math.sqrt(Math.pow(b, 2) - (4*a*c)))/(2*a); System.out.println("\nLa raiz 1 es: "+resultado1); System.out.println("\nLa raiz 2 es: "+resultado2); return 0; } }
917a6a6614f9905918578aa045cd7babb6435f55
3240d322d1debb32b93f3a1f1a1f03859f6b9230
/ClothesClientApp/src/main/java/com/example/ahmedrizk/clothesownerapp/MainActivity.java
b8622cea1ecefeaac504e03b3b1336257bcff961
[]
no_license
AhmedMahmoudRizk/Clothes-App
554118573e11979a4d857b10bc5fe8c7791808a5
7c6240d43f76f9465ff7fdae2ce7a71e0642bb23
refs/heads/master
2021-07-14T00:54:43.440512
2017-10-12T15:31:33
2017-10-12T15:31:33
104,118,022
0
0
null
null
null
null
UTF-8
Java
false
false
3,300
java
package com.example.ahmedrizk.clothesownerapp; import android.content.Intent; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.widget.Toast; public class MainActivity extends AppCompatActivity { private SectionsPagerAdapter mSectionsPagerAdapter; private ViewPager mViewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); android.app.ActionBar actionBar = getActionBar(); if(actionBar != null) { actionBar.setHomeButtonEnabled(false); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowHomeEnabled(false); } getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager)); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.about) { Intent intent=new Intent(MainActivity.this,AboutApp.class); startActivity(intent); //do something return true; } return true; } public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). if (position == 0) return Men.newInstance(position + 1); else if (position == 1) return Women.newInstance(position + 1); else return Children.newInstance(position + 1); } @Override public int getCount() { // Show 3 total pages. return 3; } } }
330435d5b24a1d2224bd2a1f44cccf9a51e9f8fe
15ab87a5513fb3f8ee5b9a35b55e56a2257121ea
/etransaction-service/src/main/java/com/eventuate/example/etransaction/configuration/ETransactionConfiguration.java
470151287c477feaee1237b7d21128f7e9d2ce20
[]
no_license
camapac/spring-boot-eventuate-local-example
64aa01e4ddf701903c62d9dc3f19ebbe944c3dc4
5f8d1e6b5b37b1c0f0397c4aa2d3925786cb1839
refs/heads/master
2022-04-02T01:30:38.493474
2020-02-05T10:23:45
2020-02-05T10:23:45
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,436
java
package com.eventuate.example.etransaction.configuration; import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import com.eventuate.example.entity.Transaction; import com.eventuate.example.etransaction.event.TransactionWorkflow; import com.eventuate.example.info.command.TransactionCommand; import io.eventuate.sync.AggregateRepository; import io.eventuate.sync.EventuateAggregateStore; import io.eventuate.javaclient.spring.EnableEventHandlers; @Configuration @EnableEventHandlers @ComponentScan public class ETransactionConfiguration { @Bean public HttpMessageConverters customConverters() { HttpMessageConverter<?> additional = new MappingJackson2HttpMessageConverter(); return new HttpMessageConverters(additional); } @Bean(name="transactionWorkflow") public TransactionWorkflow transactionWorkflow() { return new TransactionWorkflow(); } @Bean(name="transactionRepository") public AggregateRepository<Transaction, TransactionCommand> transactionRepository(EventuateAggregateStore eventStore) { return new AggregateRepository<>(Transaction.class, eventStore); } }
d8ac84be6bbce7ac3d5f5a1f0e0fba655e66b6dc
ec67ea62dbc0fa30ee42065aa92ca53ee4b25a04
/FCMDemo/app/src/main/java/com/adityadua/fcmdemo/MyFirebaseMessagingService.java
c31d796608d4c08c560851a071483431ee64854a
[]
no_license
aditya-dua/Android28July
6de5004e0e494dadd896186cd866eed878e5abf0
18781fd19fcd31be8ebd70bff48f21812dff7526
refs/heads/master
2021-07-17T05:16:47.517747
2017-10-24T17:25:56
2017-10-24T17:25:56
100,294,024
0
0
null
null
null
null
UTF-8
Java
false
false
1,910
java
package com.adityadua.fcmdemo; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.media.RingtoneManager; import android.net.Uri; import android.support.v4.app.NotificationCompat; import android.util.Log; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; /** * Created by AdityaDua on 12/10/17. */ public class MyFirebaseMessagingService extends FirebaseMessagingService { private static final String TAG = "MyFirebaseMessaging"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); // Fire a notification Log.d(TAG,"From ::"+remoteMessage.getFrom()); Log.d(TAG,"Notification / Message Body :"+remoteMessage.getNotification().getBody()); sendNotification(remoteMessage.getNotification().getBody()); } private void sendNotification(String body){ Intent intent = new Intent(this,MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT); Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificaBuilder= new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle("Push Notification") .setContentText(body) .setAutoCancel(true) .setSound(soundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0,notificaBuilder.build()); } }
635b2011b1a9e0ae47ca18cadf57c377123884f3
f0c8eb22449d567e8a215e84fbe68e4e8c5a0893
/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/CompositeFieldValidator.java
7aa075edb2a676235a671f65898f12ccbc27e41c
[ "Apache-2.0", "MIT", "BSD-3-Clause", "MIT-0", "CC-BY-2.5", "LGPL-2.0-or-later", "LicenseRef-scancode-proprietary-license", "MPL-1.0", "LicenseRef-scancode-unknown-license-reference", "LGPL-2.1-or-later", "GPL-1.0-or-later", "MPL-1.1" ]
permissive
apache/tapestry-5
6c8c9d5f1f28abe03f424b21b1ff96af9955f76d
b5bda40756c5e946901d18694a094f023ba6d2b5
refs/heads/master
2023-08-28T16:05:10.291603
2023-07-13T17:25:04
2023-07-13T17:25:04
4,416,959
89
103
Apache-2.0
2023-09-14T11:59:30
2012-05-23T07:00:11
Java
UTF-8
Java
false
false
1,700
java
// Copyright 2007, 2008 The Apache Software Foundation // // 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.apache.tapestry5.internal.services; import org.apache.tapestry5.FieldValidator; import org.apache.tapestry5.MarkupWriter; import org.apache.tapestry5.ValidationException; import java.util.List; /** * Aggregates together a number of field validator instances as a single unit. */ public final class CompositeFieldValidator implements FieldValidator { private final FieldValidator[] validators; public CompositeFieldValidator(List<FieldValidator> validators) { this.validators = validators.toArray(new FieldValidator[validators.size()]); } @SuppressWarnings("unchecked") public void validate(Object value) throws ValidationException { for (FieldValidator fv : validators) fv.validate(value); } public void render(MarkupWriter writer) { for (FieldValidator fv : validators) fv.render(writer); } public boolean isRequired() { for (FieldValidator fv : validators) { if (fv.isRequired()) return true; } return false; } }
e220e862c9be523f8a4a5e323ea7860dae948ccb
d5f09c7b0e954cd20dd613af600afd91b039c48a
/sources/com/facebook/stetho/inspector/elements/android/AndroidDocumentProviderFactory.java
87310d32bfcd4e63dc43e60773eef58f9fb8d84b
[]
no_license
t0HiiBwn/CoolapkRelease
af5e00c701bf82c4e90b1033f5c5f9dc8526f4b3
a6a2b03e32cde0e5163016e0078391271a8d33ab
refs/heads/main
2022-07-29T23:28:35.867734
2021-03-26T11:41:18
2021-03-26T11:41:18
345,290,891
5
2
null
null
null
null
UTF-8
Java
false
false
2,450
java
package com.facebook.stetho.inspector.elements.android; import android.app.Application; import android.os.Handler; import android.os.Looper; import com.facebook.stetho.common.ThreadBound; import com.facebook.stetho.common.UncheckedCallable; import com.facebook.stetho.common.Util; import com.facebook.stetho.common.android.HandlerUtil; import com.facebook.stetho.inspector.elements.DescriptorProvider; import com.facebook.stetho.inspector.elements.DocumentProvider; import com.facebook.stetho.inspector.elements.DocumentProviderFactory; import java.util.List; public final class AndroidDocumentProviderFactory implements DocumentProviderFactory, ThreadBound { private final Application mApplication; private final List<DescriptorProvider> mDescriptorProviders; private final Handler mHandler = new Handler(Looper.getMainLooper()); public AndroidDocumentProviderFactory(Application application, List<DescriptorProvider> list) { this.mApplication = (Application) Util.throwIfNull(application); this.mDescriptorProviders = (List) Util.throwIfNull(list); } @Override // com.facebook.stetho.inspector.elements.DocumentProviderFactory public DocumentProvider create() { return new AndroidDocumentProvider(this.mApplication, this.mDescriptorProviders, this); } @Override // com.facebook.stetho.common.ThreadBound public boolean checkThreadAccess() { return HandlerUtil.checkThreadAccess(this.mHandler); } @Override // com.facebook.stetho.common.ThreadBound public void verifyThreadAccess() { HandlerUtil.verifyThreadAccess(this.mHandler); } @Override // com.facebook.stetho.common.ThreadBound public <V> V postAndWait(UncheckedCallable<V> uncheckedCallable) { return (V) HandlerUtil.postAndWait(this.mHandler, uncheckedCallable); } @Override // com.facebook.stetho.common.ThreadBound public void postAndWait(Runnable runnable) { HandlerUtil.postAndWait(this.mHandler, runnable); } @Override // com.facebook.stetho.common.ThreadBound public void postDelayed(Runnable runnable, long j) { if (!this.mHandler.postDelayed(runnable, j)) { throw new RuntimeException("Handler.postDelayed() returned false"); } } @Override // com.facebook.stetho.common.ThreadBound public void removeCallbacks(Runnable runnable) { this.mHandler.removeCallbacks(runnable); } }
647c7f02b0a7ee171df5b00cbc7a4d3265daa0b2
107d33c859d4d92c400dd457d28cc61049316ba5
/src/com/amzi/servlets/GetCalendarGroupServlet.java
5cdd458ada47756ec9564f2c5e8d1e90446089b4
[]
no_license
JoeyDinardo/Calendar-Dynamic-Web-Project
1e892dab2ee9d45e55ba6e5b12a6e5c831a495ac
f753a98033e88e625195a3e32dd15ed114619726
refs/heads/master
2021-01-05T13:07:52.036545
2020-02-17T05:49:35
2020-02-17T05:49:35
241,031,331
0
0
null
null
null
null
UTF-8
Java
false
false
90,437
java
package com.amzi.servlets; import java.io.IOException; import java.io.PrintWriter; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Enumeration; import java.util.GregorianCalendar; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.google.gson.Gson; import com.amzi.dao.Message; import com.amzi.dao.calendarDB; @WebServlet ("/getCalendarGroup") public class GetCalendarGroupServlet extends HttpServlet{ private static final long serialVersionUID = 1L; public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("GetCalendarGroupServlet"); Message message = new Message(); String calendarName = request.getParameter("calendarName"); String group = request.getParameter("group"); String [] month = request.getParameterValues ("monthForm"); String [] year = request.getParameterValues ("yearForm"); System.out.println("calendarName " + calendarName); String calendarHtml =""; Calendar calendar = new GregorianCalendar(1,Integer.parseInt (month [0]),Integer.parseInt (year [0])); int startDay = calendar.get(Calendar.DAY_OF_WEEK); String calendarValues [] = calendarDB.getCalendarGroupValues (group,calendarName, month [0],year [0]); System.out.println(calendarValues.length); for (int i = 0; i < calendarValues.length;i++){ System.out.println("calendar values " + calendarValues [i]); } if (month [0].equals ("0") || month [0].equals ("2") ||month [0].equals ("4") || month [0].equals ("6") || month [0].equals ("7") || month [0].equals ("9") || month [0].equals ("11")){ if (startDay == 7){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr><tr><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td></tr><tr><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td></tr><tr><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td></tr><tr><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td></tr><tr><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td><td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td></tr><tr><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td></tr> <tr> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td><td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td><td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td></td></tr><tr><td>29</td><td>30</td><td>31</td></tr> <tr> <td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td><td><textarea style= overflow:hidden name = 32 id = 32 form= dayform>" + calendarValues [31] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 1){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td></tr><tr><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td></tr><tr><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td></tr><tr><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td></tr><tr><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td></tr><tr><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td></tr> <tr> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td><td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td></td></tr><tr><td>28</td><td>29</td><td>30</td><td>31</td></tr> <tr> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td><td><textarea style= overflow:hidden name = 32 id = 32 form= dayform>" + calendarValues [31] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 2){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr><tr><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td></tr><tr><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td></tr><tr><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td></tr><tr><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td></tr><tr><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td></tr><tr><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td></tr> <tr><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td><td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td></tr><tr><td>27</td><td>28</td><td>29</td><td>30</td><td>31</td></tr> <tr> <td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td><td><textarea style= overflow:hidden name = 32 id = 32 form= dayform>" + calendarValues [31] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 3){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td>1</td><td>2</td><td>3</td><td>4</td></tr><tr><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td></tr><tr><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td></tr><tr><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td></tr><tr><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td></tr><tr><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td></tr><tr><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td></tr> <tr><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td></tr><tr><td>26</td><td>27</td><td>28</td><td>29</td><td>30</td><td>31</td></tr> <tr> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td><td><textarea style= overflow:hidden name = 32 id = 32 form= dayform>" + calendarValues [31] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 4){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td></td><td>1</td><td>2</td><td>3</td></tr><tr><td></td><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td></tr><tr><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td></tr><tr><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td></tr><tr><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> </tr><tr><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td></tr> <tr><td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td></tr><tr><td>25</td><td>26</td><td>27</td><td>28</td><td>29</td><td>30</td><td>31</td></tr> <tr><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td><td><textarea style= overflow:hidden name = 32 id = 32 form= dayform>" + calendarValues [31] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 5){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td></td><td></td><td>1</td><td>2</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td></tr><tr><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td></tr><tr><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td></tr><tr><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td></tr><tr><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> </tr><tr><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td></tr> <tr><td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td><td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td></tr><tr><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td><td>29</td><td>30</td></tr> <tr><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td></tr><tr><td>31</td><tr><td><textarea style= overflow:hidden name = 32 id = 32 form= dayform>" + calendarValues [31] + " </textarea></td></tr></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 6){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td>1</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> </tr><tr><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td></tr><tr><td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td></tr><tr><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td></tr><tr><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td> </tr><tr><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td></tr> <tr><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td><td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td></tr><tr><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td><td>29</td></tr> <tr><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td></tr><tr><td>30</td><td>31</td></tr><tr><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td><td><textarea style= overflow:hidden name = 32 id = 32 form= dayform>" + calendarValues [31] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } } else if (month [0].equals ("3") || month [0].equals ("5") ||month [0].equals ("8") || month [0].equals ("10") ){ if (startDay == 7){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr><tr><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td></tr><tr><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td></tr><tr><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td></tr><tr><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td></tr><tr><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td><td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td></tr><tr><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td></tr> <tr> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td><td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td><td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td></td></tr><tr><td>29</td><td>30</td></tr> <tr> <td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 1){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td></tr><tr><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td></tr><tr><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td></tr><tr><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td></tr><tr><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td></tr><tr><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td></tr> <tr> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td><td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td></td></tr><tr><td>28</td><td>29</td><td>30</td></tr> <tr> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 2){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr><tr><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td></tr><tr><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td></tr><tr><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td></tr><tr><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td></tr><tr><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td></tr><tr><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td></tr> <tr><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td><td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td></tr><tr><td>27</td><td>28</td><td>29</td><td>30</td></tr> <tr> <td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 3){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td>1</td><td>2</td><td>3</td><td>4</td></tr><tr><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td></tr><tr><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td></tr><tr><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td></tr><tr><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td></tr><tr><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td></tr><tr><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td></tr> <tr><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td></tr><tr><td>26</td><td>27</td><td>28</td><td>29</td><td>30</td></tr> <tr> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 4){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td></td><td>1</td><td>2</td><td>3</td></tr><tr><td></td><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td></tr><tr><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td></tr><tr><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td></tr><tr><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> </tr><tr><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td></tr> <tr><td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td></tr><tr><td>25</td><td>26</td><td>27</td><td>28</td><td>29</td><td>30</td></tr> <tr><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 5){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td></td><td></td><td>1</td><td>2</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td></tr><tr><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td></tr><tr><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td></tr><tr><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td></tr><tr><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> </tr><tr><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td></tr> <tr><td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td><td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td></tr><tr><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td><td>29</td><td>30</td></tr> <tr><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 6){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td>1</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> </tr><tr><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td></tr><tr><td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td></tr><tr><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td></tr><tr><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td> </tr><tr><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td></tr> <tr><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td><td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td></tr><tr><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td><td>29</td></tr> <tr><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td><td><textarea style= overflow:hidden name = 30 id = 30 form= dayform>" + calendarValues [29] + " </textarea></td></tr><tr><td>30</td></tr><tr><td><textarea style= overflow:hidden name = 31 id = 31 form= dayform>" + calendarValues [30] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } } else if (month [0].equals("1")){ if (startDay == 7){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td></tr><tr><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td></tr><tr><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td></tr><tr><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td></tr><tr><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td></tr><tr><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td><td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td></tr><tr><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td></tr> <tr> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td><td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td><td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td></td></tr><tr></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 1){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td></tr><tr><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td></tr><tr><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td></tr><tr><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td></tr><tr><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td></tr><tr><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td></tr> <tr> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td><td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td></td></tr><tr><td>28</td></tr> <tr> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 2){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr><tr><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td></tr><tr><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td></tr><tr><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td></tr><tr><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td></tr><tr><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td></tr><tr><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td></tr> <tr><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td><td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td></tr><tr><td>27</td><td>28</td></tr> <tr> <td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 3){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td>1</td><td>2</td><td>3</td><td>4</td></tr><tr><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td></tr><tr><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td></tr><tr><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td></tr><tr><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td></tr><tr><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> <td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td></tr><tr><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td></tr> <tr><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td></tr><tr><td>26</td><td>27</td><td>28</td></tr> <tr> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 4){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td></td><td>1</td><td>2</td><td>3</td></tr><tr><td></td><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td></tr><tr><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td></tr><tr><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td></tr><tr><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td> </tr><tr><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td></tr> <tr><td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td></tr><tr><td>25</td><td>26</td><td>27</td><td>28</td></tr> <tr><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 5){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td></td><td></td><td>1</td><td>2</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> <td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td></tr><tr><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td></tr><tr><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td></tr><tr><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td></tr><tr><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> </tr><tr><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td></tr> <tr><td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td><td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td></tr><tr><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td></tr> <tr><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } else if (startDay == 6){ calendarHtml = "<table id = tables ><tr><th>Sunday &nbsp; &nbsp; &nbsp;</th><th>Monday &nbsp; &nbsp; &nbsp;</th><th>Tuesday &nbsp; &nbsp;</th><th>Wednesday</th><th>Thursday &nbsp;</th><th>Friday &nbsp; &nbsp; &nbsp;</th><th>Saturday &nbsp; &nbsp;</th></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td>1</td><td></td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td><textarea style= overflow:hidden name = 2 id = 2 form= dayform>" + calendarValues [1] + " </textarea></td> </tr><tr><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td></tr><tr><td><textarea style= overflow:hidden name = 3 id = 3 form= dayform> " + calendarValues [2] + " </textarea></td><td><textarea style= overflow:hidden name = 4 id = 4 form= dayform>" + calendarValues [3] + " </textarea></td><td><textarea style= overflow:hidden name = 5 id = 5 form= dayform>" + calendarValues [4] + " </textarea></td><td><textarea style= overflow:hidden name = 6 id = 6 form= dayform>" + calendarValues [5] + " </textarea></td><td><textarea style= overflow:hidden name = 7 id = 7 form= dayform> " + calendarValues [6] + " </textarea></td><td><textarea style= overflow:hidden name = 8 id = 8 form= dayform>" + calendarValues [7] + " </textarea></td><td><textarea style= overflow:hidden name = 9 id = 9 form= dayform>" + calendarValues [8] + " </textarea></td></tr><tr><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td></tr><tr><td><textarea style= overflow:hidden name = 10 id = 10 form= dayform> " + calendarValues [9] + "</textarea></td><td><textarea style= overflow:hidden name = 11 id = 11 form= dayform>" + calendarValues [10] + " </textarea></td><td><textarea style= overflow:hidden name = 12 id = 12 form= dayform>" + calendarValues [11] + " </textarea></td><td><textarea style= overflow:hidden name = 13 id = 13 form= dayform>" + calendarValues [12] + " </textarea></td><td><textarea style= overflow:hidden name = 14 id = 14 form= dayform>" + calendarValues [13] + " </textarea></td><td><textarea style= overflow:hidden name = 15 id = 15 form= dayform>" + calendarValues [14] + " </textarea></td><td><textarea style= overflow:hidden name = 16 id = 16 form= dayform>" + calendarValues [15] + " </textarea></td> </tr><tr><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td></tr> <tr><td><textarea style= overflow:hidden name = 17 id = 17 form= dayform>" + calendarValues [16] + " </textarea></td> <td><textarea style= overflow:hidden name = 18 id = 18 form= dayform>" + calendarValues [17] + " </textarea></td><td><textarea style= overflow:hidden name = 19 id = 19 form= dayform>" + calendarValues [18] + " </textarea></td><td><textarea style= overflow:hidden name = 20 id = 20 form= dayform>" + calendarValues [19] + " </textarea></td><td><textarea style= overflow:hidden name = 21 id = 21 form= dayform>" + calendarValues [20] + " </textarea></td> <td><textarea style= overflow:hidden name = 22 id = 22 form= dayform>" + calendarValues [21] + " </textarea></td> <td><textarea style= overflow:hidden name = 23 id = 23 form= dayform>" + calendarValues [22] + " </textarea></td></tr><tr><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td></tr> <tr><td><textarea style= overflow:hidden name = 24 id = 24 form= dayform>" + calendarValues [23] + " </textarea></td><td><textarea style= overflow:hidden name = 25 id = 25 form= dayform>" + calendarValues [24] + " </textarea></td><td><textarea style= overflow:hidden name = 26 id = 26 form= dayform>" + calendarValues [25] + " </textarea></td> <td><textarea style= overflow:hidden name = 27 id = 27 form= dayform>" + calendarValues [26] + " </textarea></td><td><textarea style= overflow:hidden name = 28 id = 28 form= dayform>" + calendarValues [27] + " </textarea></td> <td><textarea style= overflow:hidden name = 29 id = 29 form= dayform>" + calendarValues [28] + " </textarea></td></tr><tr><td><input type = button value = Save id = Save onclick = saveValue()></td></tr></table>"; } } message.setText(calendarHtml); Gson gson = new Gson(); String content = gson.toJson(message); response.setContentType("text/json"); response.getWriter().print(content); } }
6bea7a23bd68e106cd0637284eab194210db54ff
a5d4fdafa9a90d01282a2db0f954329e01de5836
/alfresco-dropbox-repo/src/main/java/org/alfresco/dropbox/service/polling/DropboxPollerImpl.java
124d3697b56db5a91e39a8f02ad3fcf8dd0e7041
[ "Apache-2.0" ]
permissive
jottley/alfresco-dropbox-integration
acd675e1eaef6c65be90fbb1cdabae5099741fbf
f9fac13b7a7a0f2969f1f959641e24749fb49294
refs/heads/master
2020-04-09T04:04:39.328430
2012-08-19T03:43:13
2012-08-19T03:43:13
32,124,745
0
1
null
null
null
null
UTF-8
Java
false
false
24,207
java
/* * Copyright 2011-2012 Alfresco Software Limited. * * 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. * * This file is part of an unsupported extension to Alfresco. */ package org.alfresco.dropbox.service.polling; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.regex.Matcher; import org.alfresco.dropbox.DropboxConstants; import org.alfresco.dropbox.exceptions.NotModifiedException; import org.alfresco.dropbox.service.DropboxService; import org.alfresco.model.ContentModel; import org.alfresco.repo.search.impl.lucene.LuceneQueryParserException; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentIOException; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.transaction.TransactionService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.WebScriptException; import org.springframework.social.dropbox.api.Metadata; /** * * * @author Jared Ottley */ public class DropboxPollerImpl implements DropboxPoller { private static final Log log = LogFactory.getLog(DropboxPollerImpl.class); private SearchService searchService; private NodeService nodeService; private FileFolderService fileFolderService; private TransactionService transactionService; private DropboxService dropboxService; private static final String CMIS_DROPBOX_SITES_QUERY = "SELECT * FROM st:site AS S JOIN db:syncable AS O ON S.cmis:objectId = O.cmis:objectId"; private static final String CMIS_DROPBOX_DOCUMENTS_QUERY = "SELECT D.* FROM cmis:document AS D JOIN db:dropbox AS O ON D.cmis:objectId = O.cmis:objectId"; private static final String CMIS_DROPBOX_FOLDERS_QUERY = "SELECT F.* FROM cmis:folder AS F JOIN db:dropbox AS O ON F.cmis:objectId = O.cmis:objectId"; private static final NodeRef MISSING_NODE = new NodeRef("missing://missing/missing"); public void setSearchService(SearchService searchService) { this.searchService = searchService; } public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; } public void setFileFolderService(FileFolderService fileFolderService) { this.fileFolderService = fileFolderService; } public void setTransactionService(TransactionService transactionService) { this.transactionService = transactionService; } public void setDropboxService(DropboxService dropboxService) { this.dropboxService = dropboxService; } public void execute() { log.debug("Dropbox poller initiated."); // TODO where should the authentication and transactions go? AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() { public Object doWork() throws Exception { RetryingTransactionCallback<Object> txnWork = new RetryingTransactionCallback<Object>() { public Object execute() throws Exception { List<NodeRef> sites = getSites(); List<NodeRef> folders = null; List<NodeRef> documents = null; if (sites != null) { for (NodeRef site : sites) { if (!isSyncing(site)) { log.debug("Processing Content in " + nodeService.getProperty(site, ContentModel.PROP_NAME)); try { syncOn(site); folders = getFolders(site); documents = getDocuments(site); if (documents != null) { // If the document is the child of a synced folder...we want to work on the folder as a // full collection and not the document as an independent element Iterator<NodeRef> i = documents.iterator(); while (i.hasNext()) { NodeRef document = i.next(); if (folders.contains(nodeService.getPrimaryParent(document).getParentRef())) { i.remove(); } } if (documents.size() > 0) { for (NodeRef document : documents) { updateNode(document); } } } if (folders.size() > 0) { for (NodeRef folder : folders) { log.debug("Looking for updates/new content in " + nodeService.getProperty(folder, ContentModel.PROP_NAME)); try { Metadata metadata = dropboxService.getMetadata(folder); // Get the list of the content returned. List<Metadata> list = metadata.getContents(); for (Metadata child : list) { String name = child.getPath().replaceAll(Matcher.quoteReplacement(metadata.getPath() + "/"), ""); NodeRef childNodeRef = fileFolderService.searchSimple(folder, name); if (childNodeRef == null) { addNode(folder, child, name); } else { updateNode(childNodeRef, child); } } metadata = dropboxService.getMetadata(folder); dropboxService.persistMetadata(metadata, folder); } catch (NotModifiedException nme) { // TODO } } } } finally { syncOff(site); log.debug("End processing " + nodeService.getProperty(site, ContentModel.PROP_NAME)); documents = null; folders = null; } } } } return null; } }; transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, false); return null; } }, AuthenticationUtil.getAdminUserName()); } private List<NodeRef> getSites() { List<NodeRef> sites = new ArrayList<NodeRef>(); ResultSet resultSet = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<ResultSet>() { public ResultSet doWork() throws Exception { ResultSet resultSet = null; try { resultSet = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_CMIS_ALFRESCO, CMIS_DROPBOX_SITES_QUERY); } catch (LuceneQueryParserException lqpe) { // This is primarily to handle the case where the dropbox model has not been added to solr yet. Incidentally it // catches other failures too ;) log.info("Unable to perform site query: " + lqpe.getMessage()); } return resultSet; } }, AuthenticationUtil.getAdminUserName()); // TODO Hopefully one day this will go away --Open Bug?? try { if (resultSet.length() > 0) { if (!resultSet.getNodeRef(0).equals(MISSING_NODE)) { sites = resultSet.getNodeRefs(); log.debug("Sites with Dropbox content: " + sites); } } } finally { resultSet.close(); } return sites; } private List<NodeRef> getDocuments(final NodeRef nodeRef) { List<NodeRef> documents = Collections.synchronizedList(new ArrayList<NodeRef>()); ResultSet resultSet = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<ResultSet>() { public ResultSet doWork() throws Exception { ResultSet resultSet = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_CMIS_ALFRESCO, CMIS_DROPBOX_DOCUMENTS_QUERY + " WHERE IN_TREE(D, '" + nodeRef + "')"); return resultSet; } }, AuthenticationUtil.getAdminUserName()); try { // TODO Hopefully one day this will go away --Open Bug?? if (resultSet.length() > 0) { if (!resultSet.getNodeRef(0).equals(MISSING_NODE)) { documents = resultSet.getNodeRefs(); log.debug("Documents synced to Dropbox: " + documents); } } } finally { resultSet.close(); } return documents; } private List<NodeRef> getFolders(final NodeRef nodeRef) { List<NodeRef> folders = Collections.synchronizedList(new ArrayList<NodeRef>()); ResultSet resultSet = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<ResultSet>() { public ResultSet doWork() throws Exception { ResultSet resultSet = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_CMIS_ALFRESCO, CMIS_DROPBOX_FOLDERS_QUERY + " WHERE IN_TREE(F, '" + nodeRef + "')"); return resultSet; } }, AuthenticationUtil.getAdminUserName()); try { // TODO Hopefully one day this will go away --Open Bug?? if (resultSet.length() > 0) { if (!resultSet.getNodeRef(0).equals(MISSING_NODE)) { folders = resultSet.getNodeRefs(); log.debug("Folders synced to Dropbox: " + folders); } } } finally { resultSet.close(); } return folders; } private void updateNode(final NodeRef nodeRef) { Metadata metadata = dropboxService.getMetadata(nodeRef); updateNode(nodeRef, metadata); } private void updateNode(final NodeRef nodeRef, final Metadata metadata) { AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() { public Object doWork() throws Exception { RetryingTransactionCallback<Object> txnWork = new RetryingTransactionCallback<Object>() { public Object execute() throws Exception { if (nodeService.getType(nodeRef).equals(ContentModel.TYPE_FOLDER)) { try { Metadata metadata = dropboxService.getMetadata(nodeRef); // Get the list of the content returned. List<Metadata> list = metadata.getContents(); for (Metadata child : list) { String name = child.getPath().replaceAll(Matcher.quoteReplacement(metadata.getPath() + "/"), ""); NodeRef childNodeRef = fileFolderService.searchSimple(nodeRef, name); if (childNodeRef == null) { addNode(nodeRef, child, name); } else { updateNode(childNodeRef, child); } } metadata = dropboxService.getMetadata(nodeRef); dropboxService.persistMetadata(metadata, nodeRef); } catch (NotModifiedException nme) { } } else { Serializable rev = nodeService.getProperty(nodeRef, DropboxConstants.Model.PROP_REV); if (!metadata.getRev().equals(rev)) { Metadata metadata = null; try { metadata = dropboxService.getFile(nodeRef); } catch (ContentIOException cio) { cio.printStackTrace(); } if (metadata != null) { dropboxService.persistMetadata(metadata, nodeRef); } else { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Dropbox metadata maybe out of sync for " + nodeRef); } } } return null; } }; transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, false); return null; } }, AuthenticationUtil.getAdminUserName()); } private void addNode(final NodeRef parentNodeRef, final Metadata metadata, final String name) { AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() { public Object doWork() throws Exception { NodeRef nodeRef = null; if (metadata.isDir()) { RetryingTransactionCallback<NodeRef> txnWork = new RetryingTransactionCallback<NodeRef>() { public NodeRef execute() throws Exception { NodeRef nodeRef = null; nodeRef = fileFolderService.create(parentNodeRef, name, ContentModel.TYPE_FOLDER).getNodeRef(); Metadata metadata = dropboxService.getMetadata(nodeRef); List<Metadata> list = metadata.getContents(); for (Metadata child : list) { String name = child.getPath().replaceAll(Matcher.quoteReplacement(metadata.getPath() + "/"), ""); addNode(nodeRef, child, name); } return nodeRef; } }; nodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, false); } else { log.debug("Adding " + metadata.getPath() + " to Alfresco"); RetryingTransactionCallback<NodeRef> txnWork = new RetryingTransactionCallback<NodeRef>() { public NodeRef execute() throws Exception { NodeRef nodeRef = null; try { nodeRef = fileFolderService.create(parentNodeRef, name, ContentModel.TYPE_CONTENT).getNodeRef(); Metadata metadata = dropboxService.getFile(nodeRef); dropboxService.persistMetadata(metadata, parentNodeRef); } catch (ContentIOException cio) { cio.printStackTrace(); } return nodeRef; } }; nodeRef = transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, false); } dropboxService.persistMetadata(metadata, nodeRef); return null; } }, AuthenticationUtil.getAdminUserName()); } private boolean isSyncing(final NodeRef nodeRef) { Boolean syncing = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Boolean>() { public Boolean doWork() throws Exception { RetryingTransactionCallback<Boolean> txnWork = new RetryingTransactionCallback<Boolean>() { public Boolean execute() throws Exception { boolean syncing = false; if (nodeRef != null) { List<ChildAssociationRef> childAssoc = nodeService.getChildAssocs(nodeRef, DropboxConstants.Model.ASSOC_SYNC_DETAILS, DropboxConstants.Model.DROPBOX); if (childAssoc.size() == 1) { syncing = Boolean.valueOf(nodeService.getProperty(childAssoc.get(0).getChildRef(), DropboxConstants.Model.PROP_SYNCING).toString()); } } return syncing; } }; boolean syncing = transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, false); return syncing; } }, AuthenticationUtil.getAdminUserName()); return syncing; } private void syncOn(NodeRef site) { sync(site, true); } private void syncOff(NodeRef site) { sync(site, false); } private void sync(final NodeRef site, final boolean sync) { AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() { public Object doWork() throws Exception { RetryingTransactionCallback<Object> txnWork = new RetryingTransactionCallback<Object>() { public Object execute() throws Exception { if (nodeService.hasAspect(site, DropboxConstants.Model.ASPECT_SYNCABLE)) { List<ChildAssociationRef> childAssoc = nodeService.getChildAssocs(site, DropboxConstants.Model.ASSOC_SYNC_DETAILS, DropboxConstants.Model.DROPBOX); if (childAssoc.size() == 1) { nodeService.setProperty(childAssoc.get(0).getChildRef(), DropboxConstants.Model.PROP_SYNCING, sync); } } return null; } }; transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, false); return null; } }, AuthenticationUtil.getAdminUserName()); } }
b81dd271bb77249e2edf7fae34aed807c3914d51
fa91450deb625cda070e82d5c31770be5ca1dec6
/Diff-Raw-Data/2/2_79d5a8f82f78a42fe64c9077a3b810f9c15f2d9d/MyMediaPlayerActivity/2_79d5a8f82f78a42fe64c9077a3b810f9c15f2d9d_MyMediaPlayerActivity_s.java
2ea333f7932d7eabaade0f842de7cc0b4978fa65
[]
no_license
zhongxingyu/Seer
48e7e5197624d7afa94d23f849f8ea2075bcaec0
c11a3109fdfca9be337e509ecb2c085b60076213
refs/heads/master
2023-07-06T12:48:55.516692
2023-06-22T07:55:56
2023-06-22T07:55:56
259,613,157
6
2
null
2023-06-22T07:55:57
2020-04-28T11:07:49
null
UTF-8
Java
false
false
8,108
java
package com.example.testapplication; import android.app.Activity; import android.content.Context; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import android.media.AudioManager; import android.os.Bundle; import android.os.Environment; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class MyMediaPlayerActivity extends Activity { WakeLock wakeLock; private static final String[] EXTENSIONS = {".mp3", ".mid", ".wav", ".ogg", ".mp4"}; //Playable Extensions List<String> trackNames; //Playable Track Titles List<String> trackArtworks; //Track artwork names AssetManager assets; //Assets (Compiled with APK) Music track; //currently loaded track Button btnPlay; //The play button will need to change from 'play' to 'pause', so we need an instance of it boolean isTuning; //is user currently jammin out, if so automatically start playing the next track int currentTrack; //index of current track selected int type; //0 for loading from assets, 1 for loading from SD card @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setVolumeControlStream(AudioManager.STREAM_MUSIC); PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "Lexiconda"); setContentView(R.layout.musicplayer); initialize(0); } @Override public void onResume() { super.onResume(); wakeLock.acquire(); } @Override public void onPause() { super.onPause(); wakeLock.release(); if (track != null) { if (track.isPlaying()) { track.pause(); isTuning = false; btnPlay.setBackgroundResource(R.drawable.play); } if (isFinishing()) { track.dispose(); finish(); } } else { if (isFinishing()) { finish(); } } } private void initialize(int type) { btnPlay = (Button) findViewById(R.id.btnPlay); btnPlay.setBackgroundResource(R.drawable.play); trackNames = new ArrayList<String>(); trackArtworks = new ArrayList<String>(); assets = getAssets(); currentTrack = 0; isTuning = false; this.type = type; addTracks(getTracks()); loadTrack(); } //Generate a String Array that represents all of the files found private String[] getTracks() { try { String[] temp = getAssets().list(""); return temp; } catch (IOException e) { e.printStackTrace(); } return null; } //Adds the playable files to the trackNames List private void addTracks(String[] temp) { if (temp != null) { for (int i = 0; i < temp.length; i++) { //Only accept files that have one of the extensions in the EXTENSIONS array if (trackChecker(temp[i])) { trackNames.add(temp[i]); trackArtworks.add(temp[i].substring(0, temp[i].length() - 4)); } } } } //Checks to make sure that the track to be loaded has a correct extenson private boolean trackChecker(String trackToTest) { for (int j = 0; j < EXTENSIONS.length; j++) { if (trackToTest.contains(EXTENSIONS[j])) { return true; } } return false; } //Loads the track by calling loadMusic private void loadTrack() { if (track != null) { track.dispose(); } if (trackNames.size() > 0) { track = loadMusic(type); } } //loads a Music instance using either a built in asset or an external resource private Music loadMusic(int type) { switch (type) { case 0: try { AssetFileDescriptor assetDescriptor = assets.openFd(trackNames.get(currentTrack)); return new Music(assetDescriptor); } catch (IOException e) { e.printStackTrace(); } return null; case 1: try { FileInputStream fis = new FileInputStream(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC), trackNames.get(currentTrack))); FileDescriptor fileDescriptor = fis.getFD(); return new Music(fileDescriptor); } catch (IOException e) { e.printStackTrace(); } return null; default: return null; } } @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); createMenu(menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 0: //Set Looping synchronized (this) { if (track.isLooping()) { track.setLooping(false); } else { track.setLooping(true); } } return true; case 1: //Stop Music synchronized (this) { track.switchTracks(); btnPlay.setBackgroundResource(R.drawable.play); } return true; default: return false; } } private void createMenu(Menu menu) { MenuItem miLooping = menu.add(0, 0, 0, "Looping"); { miLooping.setIcon(R.drawable.looping); } MenuItem miStop = menu.add(0, 1, 1, "Stop"); { miStop.setIcon(R.drawable.stop); } } public void click(View view) { int id = view.getId(); switch (id) { case R.id.btnPlay: synchronized (this) { if (isTuning) { isTuning = false; btnPlay.setBackgroundResource(R.drawable.play); track.pause(); } else { isTuning = true; btnPlay.setBackgroundResource(R.drawable.pause); playTrack(); } } return; case R.id.btnPrevious: setTrack(0); loadTrack(); playTrack(); return; case R.id.btnNext: setTrack(1); loadTrack(); playTrack(); return; default: return; } } private void setTrack(int direction) { if (direction == 0) { currentTrack--; if (currentTrack < 0) { currentTrack = trackNames.size() - 1; } } else if (direction == 1) { currentTrack++; if (currentTrack > trackNames.size() - 1) { currentTrack = 0; } } } //Plays the Track private void playTrack() { if (isTuning && track != null) { track.play(); } } }
15c687946b8e07767ff87ff6cbd4acc494029df1
e4f358f1cb33855f4d1a87810c17611f63fb0523
/src/main/java/cl/accenture/curso_java/playlist/dao/UsuarioDAO.java
56fc5a9a143866f7fae18e42ad57a64c66a6d782
[]
no_license
juannfrancisco/playlist-web
1ee6c2bd9c41398d7b0132329351d3f7045d8f0f
a26ce3794d1598e9b1c3e1e903a249b1e02a0d6b
refs/heads/master
2021-08-20T08:48:40.424315
2017-11-28T16:53:27
2017-11-28T16:53:27
109,014,240
0
3
null
null
null
null
UTF-8
Java
false
false
3,612
java
/** * */ package cl.accenture.curso_java.playlist.dao; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; import cl.accenture.curso_java.playlist.modelo.Conexion; import cl.accenture.curso_java.playlist.modelo.ObjetoNoEncontradoException; import cl.accenture.curso_java.playlist.modelo.Perfil; import cl.accenture.curso_java.playlist.modelo.SinConexionException; import cl.accenture.curso_java.playlist.modelo.Usuario; /** * @author jmaldonado * */ public class UsuarioDAO { /** * * @param usuario * @return * @throws SQLException * @throws SinConexionException */ public static Usuario validar(Usuario usuario) throws SQLException, SinConexionException { PreparedStatement st = Conexion.getInstancia().prepareStatement( "select * from usuario where "+ "userName =? AND "+ "password = ?;"); st.setString(1, usuario.getNombreUsuario() ); st.setString(2, usuario.getPassword() ); ResultSet rs = st.executeQuery(); if( rs.next() ){ Perfil perfil =PerfilDAO.obtenerPerfil( rs.getInt("id_perfil") ) ; usuario.setPerfil(perfil); usuario.setUltimoIngreso( rs.getDate("ultimoIngreso") ); usuario.setIntentosFallidos( rs.getInt("intentosFallidos" ) ); return usuario; } throw new ObjetoNoEncontradoException("Usuario y/o password incorrectos"); } /** * * @return * @throws SinConexionException * @throws SQLException */ public static List<Usuario> obtenerUsuarios() throws SQLException, SinConexionException { List<Usuario> usuarios = new ArrayList<Usuario>(); PreparedStatement st = Conexion.getInstancia().prepareStatement( "select * from usuario"); ResultSet rs = st.executeQuery(); while( rs.next() ){ Usuario usuario = new Usuario(); Perfil perfil =PerfilDAO.obtenerPerfil( rs.getInt("id_perfil") ) ; usuario.setPerfil(perfil); usuario.setNombreUsuario( rs.getString("userName") ); usuario.setUltimoIngreso( rs.getTimestamp("ultimoIngreso") ); usuario.setIntentosFallidos( rs.getInt("intentosFallidos" ) ); usuarios.add( usuario ); } return usuarios; } /** * * @param usuario * @throws SinConexionException * @throws SQLException */ public static void eliminarUsuario(Usuario usuario) throws SQLException, SinConexionException { PreparedStatement st = Conexion.getInstancia().prepareStatement( "delete from usuario where userName = ?;"); st.setString(1, usuario.getNombreUsuario() ); st.executeUpdate(); } /** * * @param usuario * @throws SQLException * @throws SinConexionException */ public static void actualizarUltimoIngreso( Usuario usuario ) throws SQLException, SinConexionException{ PreparedStatement st = Conexion.getInstancia().prepareStatement( "update usuario set ultimoIngreso=? where userName = ?;"); st.setTimestamp(1, new Timestamp( new java.util.Date().getTime() )); // st.setDate(1, new Date( new java.util.Date().getTime() )); st.setString( 2, usuario.getNombreUsuario()); st.executeUpdate(); } /** * * @param usuario * @throws SQLException * @throws SinConexionException */ public static void agregarUsuario(Usuario usuario) throws SQLException, SinConexionException { PreparedStatement st = Conexion.getInstancia().prepareStatement( "insert into usuario (userName, password, id_perfil ) values(?,?, ?);"); st.setString(1,usuario.getNombreUsuario() ); st.setString(2,usuario.getPassword() ); st.setInt(3, usuario.getPerfil().getId()); st.executeUpdate(); } }
ae82efff42f5ec8ea3fd39da7f6e4e3d7ef1f99b
40c419c31b0f0ed392ee9d9d41973b6a777a8efb
/tags/start/JOpenPlatformManager/src/org/dyndns/widerstand/openplatformmanager/DeleteJPanel.java
18e398de3d7cfdd3213acf0564559b83314d6d07
[ "BSD-3-Clause" ]
permissive
pradeepk/globalplatform
c62e5b5711e8b96d5be98fa6aa7028dc821870ce
839afc6381ea7217721116aed8ef7df4086930dc
refs/heads/master
2021-01-10T04:36:14.314098
2013-03-04T18:24:59
2013-03-04T18:24:59
8,510,372
0
1
null
null
null
null
UTF-8
Java
false
false
12,174
java
/* * DeleteJPanel.java * * Created on 21. Februar 2005, 09:26 */ package org.dyndns.widerstand.openplatformmanager; import java.io.File; import java.io.IOException; import javax.swing.*; import org.dyndns.widerstand.OpenPlatform.*; import java.util.*; /** * * @author Widerstand */ public class DeleteJPanel extends javax.swing.JPanel { private MainJFrame parent; private ArrayList<JCheckBox> checkBoxList = new ArrayList<JCheckBox>(10); /** Creates new form DeleteJPanel */ public DeleteJPanel(MainJFrame parent) { this.parent = parent; initComponents(); } /** 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. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jScrollPane1 = new javax.swing.JScrollPane(); jPanel8 = new javax.swing.JPanel(); jPanel7 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); jPanel5 = new javax.swing.JPanel(); jPanel6 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); setLayout(new java.awt.BorderLayout()); setBorder(new javax.swing.border.CompoundBorder(null, new javax.swing.border.CompoundBorder(new javax.swing.border.TitledBorder("Delete Application"), new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5))))); jPanel8.setLayout(new java.awt.GridBagLayout()); jPanel7.setLayout(new javax.swing.BoxLayout(jPanel7, javax.swing.BoxLayout.Y_AXIS)); jPanel2.setLayout(new java.awt.GridLayout(0, 5)); jPanel2.setBorder(new javax.swing.border.CompoundBorder(new javax.swing.border.TitledBorder("Card Manager"), new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5)))); jPanel2.setMinimumSize(new java.awt.Dimension(600, 36)); jPanel2.setPreferredSize(new java.awt.Dimension(600, 36)); jPanel7.add(jPanel2); jPanel1.setLayout(new java.awt.GridLayout(0, 5)); jPanel1.setBorder(new javax.swing.border.CompoundBorder(new javax.swing.border.TitledBorder("Executable Load Files"), new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5)))); jPanel7.add(jPanel1); jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS)); jPanel3.setBorder(new javax.swing.border.CompoundBorder(new javax.swing.border.TitledBorder("Applications"), new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5)))); jPanel4.setLayout(new java.awt.GridLayout(0, 5)); jPanel4.setBorder(new javax.swing.border.CompoundBorder(new javax.swing.border.TitledBorder("Security Domains"), new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5)))); jPanel3.add(jPanel4); jPanel5.setLayout(new java.awt.GridLayout(0, 5)); jPanel5.setBorder(new javax.swing.border.CompoundBorder(new javax.swing.border.TitledBorder("Applications"), new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5)))); jPanel3.add(jPanel5); jPanel7.add(jPanel3); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); jPanel8.add(jPanel7, gridBagConstraints); jPanel6.setLayout(new java.awt.GridBagLayout()); jPanel6.setAlignmentY(0.0F); jButton1.setText("Delete Application(s)"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel6.add(jButton1, new java.awt.GridBagConstraints()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); jPanel8.add(jPanel6, gridBagConstraints); jScrollPane1.setViewportView(jPanel8); add(jScrollPane1, java.awt.BorderLayout.CENTER); } // </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed byte[][] AIDs; int i=0; for (int j=0; j<checkBoxList.size(); j++) { if (((JCheckBox)checkBoxList.get(j)).isSelected()) i++; } AIDs = new byte[i][]; i=0; byte[] AID; for (int j=0; j<checkBoxList.size(); j++) { JCheckBox checkBox = (JCheckBox)checkBoxList.get(j); if (checkBox.isSelected()) { AID = OPSPUtil.bytesFromHexString(checkBox.getText()); AIDs[i++] = AID; } } int approve = javax.swing.JOptionPane.showConfirmDialog(this, "Do you really want delete the application(s)?", "Delete confirmation", javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE); if (approve != javax.swing.JOptionPane.YES_OPTION) return; try { Class parameterTypes[] = new Class[] {Long.TYPE, OPSPSecurityInfo.class, OPSPCardConnectionInfo.class, byte[][].class}; Object parameters[] = new Object[] {parent.session.cardHandle, parent.session.secInfo, parent.session.cardInfo, AIDs}; OPSPReceiptData receiptData[] = (OPSPReceiptData[])WaitForMethodJDialog.showDialog(parent, "org.dyndns.widerstand.OpenPlatform.OPSPWrapper", "deleteApplet", null, parameterTypes, parameters); if (receiptData != null) { for (int j=0; j < receiptData.length; j++) { final JFileChooser fc = new JFileChooser(); int ret = fc.showSaveDialog(this); if (ret == JFileChooser.APPROVE_OPTION) { try { File file = fc.getSelectedFile(); OPSPUtil.saveOPSPReceiptData(file, receiptData[j]); } catch (IOException e) { javax.swing.JOptionPane.showMessageDialog(this, e.getMessage(), "I/O Error", javax.swing.JOptionPane.ERROR_MESSAGE); parent.refreshStatus(); return; } } } } } catch (Exception e) { for (int j=0; j<AIDs.length; j++) { byte[][] AIDsTemp = new byte[1][]; AIDsTemp[0] = AIDs[j]; try { Class parameterTypes[] = new Class[] {Long.TYPE, OPSPSecurityInfo.class, OPSPCardConnectionInfo.class, byte[][].class}; Object parameters[] = new Object[] {parent.session.cardHandle, parent.session.secInfo, parent.session.cardInfo, AIDsTemp}; OPSPReceiptData receiptData[] = (OPSPReceiptData[])WaitForMethodJDialog.showDialog(parent, "org.dyndns.widerstand.OpenPlatform.OPSPWrapper", "deleteApplet", null, parameterTypes, parameters); if (receiptData != null) { for (int k=0; k < receiptData.length; k++) { final JFileChooser fc = new JFileChooser(); int ret = fc.showSaveDialog(this); if (ret == JFileChooser.APPROVE_OPTION) { try { File file = fc.getSelectedFile(); OPSPUtil.saveOPSPReceiptData(file, receiptData[k]); } catch (IOException ex) { javax.swing.JOptionPane.showMessageDialog(this, ex.getMessage(), "I/O Error", javax.swing.JOptionPane.ERROR_MESSAGE); parent.refreshStatus(); return; } } } } } catch (OPSPException ex) { javax.swing.JOptionPane.showMessageDialog(this, ex.getMessage(), "Open Platform Error", javax.swing.JOptionPane.ERROR_MESSAGE); parent.refreshStatus(); return; } catch (Exception ex) { javax.swing.JOptionPane.showMessageDialog(this, ex.getMessage(), "Generel Error", javax.swing.JOptionPane.ERROR_MESSAGE); parent.refreshStatus(); return; } } } parent.refreshStatus(); }//GEN-LAST:event_jButton1ActionPerformed public void refresh() { JCheckBox checkBox; jPanel2.removeAll(); jPanel1.removeAll(); jPanel4.removeAll(); jPanel5.removeAll(); checkBoxList.clear(); for (OPSPApplicationData appData : parent.session.cardManager) { checkBox = new JCheckBox(OPSPUtil.toHexString(appData.getAID())); jPanel2.add(checkBox); checkBoxList.add(checkBox); } for (OPSPApplicationData appData : parent.session.loadFiles) { checkBox = new JCheckBox(OPSPUtil.toHexString(appData.getAID())); jPanel1.add(checkBox); checkBoxList.add(checkBox); } for (OPSPApplicationData appData : parent.session.securityDomains) { checkBox = new JCheckBox(OPSPUtil.toHexString(appData.getAID())); jPanel4.add(checkBox); checkBoxList.add(checkBox); } for (OPSPApplicationData appData : parent.session.applications) { checkBox = new JCheckBox(OPSPUtil.toHexString(appData.getAID())); jPanel5.add(checkBox); checkBoxList.add(checkBox); } jPanel8.revalidate(); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; private javax.swing.JPanel jPanel8; private javax.swing.JScrollPane jScrollPane1; // End of variables declaration//GEN-END:variables }
[ "(no author)@f4f2cb91-632f-4d2c-bd03-4b3085b5da43" ]
(no author)@f4f2cb91-632f-4d2c-bd03-4b3085b5da43
1c499a1928a0b542a2e3fb0ae78648511bbb47c1
b7635ffe6a2a624ee84c1fd5f4425125c72b306a
/src/main/java/com/example/demo/service/OdmUserRepo.java
35a111e5453d4a7f8a3840171d570e059098764e
[]
no_license
FanGaoXS/springboot_ldap
c0b9c2a1863b778cef416b9b0054cade5a196688
0523a5e7ee72ff5b39b586c1326fa26f2105147f
refs/heads/master
2023-01-29T22:46:33.496086
2020-12-09T10:38:47
2020-12-09T10:38:47
315,501,835
0
0
null
null
null
null
UTF-8
Java
false
false
1,208
java
package com.example.demo.service; import com.example.demo.entry.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.ldap.core.LdapTemplate; import org.springframework.stereotype.Service; import java.util.List; import static org.springframework.ldap.query.LdapQueryBuilder.query; /** * Created with IntelliJ IDEA. * * @Auther: 吴青珂 * @Date: 2020/12/09/15:47 * @Description: */ @Service public class OdmUserRepo { @Autowired private LdapTemplate ldapTemplate; /* * 新增User * */ public User create(User user){ ldapTemplate.create(user); return user; } /* * 通过cn查询User * */ public User findByCn(String cn){ return ldapTemplate.findOne(query().where("cn").is(cn),User.class); } /* * 修改User * */ public User modifyUser(User user){ ldapTemplate.update(user); return user; } /* * 删除User * */ public void deleteUser(User user){ ldapTemplate.delete(user); } /* * 查询所有User * */ public List<User> findAll(){ return ldapTemplate.findAll(User.class); } }
0a4e413efa2506d50ad9d42c7f50fe1a86962693
3e98bd275545853adbb4839cd3ad1063a88c560b
/Tanks_SS2012_Rainbowtank/lib/lib_src/eea/engine/action/basicactions/MoveBackwardAction.java
5c3a43e2d71f734eb61ec65424e7473dd3e1ebac
[]
no_license
peter89/TUD-SS2012-Tanks
4f728ef44245ac102072484e5a5cc5a15683e6fe
b8ad37b122285a495bbff872f2f5c0991a8a161a
refs/heads/master
2016-08-06T17:01:16.717725
2012-08-24T03:17:34
2012-08-24T03:17:34
null
0
0
null
null
null
null
UTF-8
Java
false
false
1,731
java
package eea.engine.action.basicactions; import org.newdawn.slick.GameContainer; import org.newdawn.slick.geom.Vector2f; import org.newdawn.slick.state.StateBasedGame; import eea.engine.component.Component; import eea.engine.interfaces.IMovement; /** * Actions können zu einem Event hinzugefügt werden. Tritt das Event ein, so werden alle * auf diesem Event registrierten Actions ausgefuehrt. * * Die Entitaet wird rueckwaerts der Bewegungsrichtung bewegt. */ public class MoveBackwardAction extends Movement implements IMovement{ /** * @param speed Geschwindigkeit der Rueckwaertsbewegung */ public MoveBackwardAction(float speed){ super(speed); } @Override public void update(GameContainer gc, StateBasedGame sb, int delta, Component event) { Vector2f position = getNextPosition(event.getOwnerEntity().getPosition(), speed, event.getOwnerEntity().getRotation(), delta);//event.getOwnerEntity().getPosition(); event.getOwnerEntity().setPosition(position); /* float rotation = event.getOwnerEntity().getRotation(); Vector2f position = event.getOwnerEntity().getPosition(); float hip = speed * delta; position.x -= hip * java.lang.Math.sin(java.lang.Math.toRadians(rotation)); position.y += hip *java.lang.Math.cos(java.lang.Math.toRadians(rotation)); */ } @Override public Vector2f getNextPosition(Vector2f position, float speed, float rotation, int delta) { Vector2f pos= new Vector2f(position); float hip = speed * delta; pos.x -= hip * java.lang.Math.sin(java.lang.Math.toRadians(rotation)); pos.y += hip *java.lang.Math.cos(java.lang.Math.toRadians(rotation)); return pos; } }
1e30b4b556df9ee48eb01de45c0eb64751d01bbf
bc4d88cf490020416afb86720cec067b32c9ff26
/src/main/java/test/ExcampleTest.java
cbac2ba813b7527a96d731cb436684378a860c72
[]
no_license
guofengma/AskMeServer
132ae605471adcdf8552b8cbcb732c15ecae91fd
c3adf2bd2210ede91c794b636bc8ae440bb4e0c7
refs/heads/master
2020-04-25T13:22:08.861566
2018-09-02T05:46:16
2018-09-02T05:46:16
null
0
0
null
null
null
null
UTF-8
Java
false
false
550
java
package test; import org.junit.After; import org.junit.Before; import org.junit.Test; import static junit.framework.TestCase.assertEquals; /** * Created by Administrator on 2018/9/2 0002. */ public class ExcampleTest { @Before public void before() { System.out.println("befor"); } @After public void after() { System.out.println("after"); } @Test public void test1(){ System.out.println("test.."); int i = 2+3; assertEquals(5,i); } }
489e6593f73a99a62d3b7470c6c3b359e488cd74
21e25a7626b593fd80c572cdb5c8ebcbcdfe66a1
/leetcode/com/practice/easy/util/TreeNode.java
dc181097fd288edddcbd24507a3c710d077dd9a5
[]
no_license
prabhakaran302/online-coding-platforms
5e5cbe837d1cb579ce0c5e75b3541110a8f0e633
3997f735f0559d5b1c28d74502543b40ad966c92
refs/heads/master
2021-06-29T03:32:43.024444
2021-06-09T17:08:21
2021-06-09T17:08:21
235,970,566
0
0
null
null
null
null
UTF-8
Java
false
false
184
java
package com.practice.easy.util; public class TreeNode { public int val; public TreeNode left; public TreeNode right; public TreeNode(int val) { super(); this.val = val; } }
aa4728c1d09e5a6b3e582964240c1a3d42c840b1
0457b703ddf204bdaa43027440929cbb3d653ff1
/KronoxScreenW/src/publicScreen/Constants.java
812b8428d4112c677d933ca35a8e244f2debe7cd
[]
no_license
dublon/Kronox
5bed6a223b9fd8ddb466d00254c65b7b953c0582
c54cdbfea92fa101feb04938aacbb36772d6af10
refs/heads/master
2020-09-24T01:17:59.937735
2019-12-03T14:49:19
2019-12-03T14:49:19
225,627,866
0
0
null
2019-12-03T13:34:08
2019-12-03T13:34:07
null
UTF-8
Java
false
false
3,490
java
package publicScreen; import java.util.ArrayList; import java.util.HashMap; import org.w3c.dom.Document; public class Constants { // Here is were you decide what to show. public static final String kronoxStringAgToday = "http://kronox-rapport.slu.se/setup/jsp/SchemaXML.jsp?startDatum=idag&intervallTyp=d&intervallAntal=1&sokMedAND=false&sprak=SV&resurser=l.M-620102%2Cl.M-620106%2Cl.M-620107%2Cl.M-620128%2Cl.M-620130%2Cl.M-620148%2Cl.M-620202%2Cl.M-620202A%2Cl.M-620212%2Cl.M-620222%2Cl.M-620223%2Cl.M-620224%2Cl.M-620224A%2Cl.M-620225%2Cl.M-620226%2Cl.M-621102%2Cl.M-621112%2Cl.M-621114%2Cl.M-621115%2Cl.M-621118%2Cl.M-621120%2Cl.M-621121A%2Cl.M-621121B%2Cl.M-621121C%2Cl.M-621207%2Cl.M-621208A%2Cl.M-621208B%2Cl.M-62120A%2Cl.M-62120B%2Cl.M-62120C%2Cl.M-621210A%2Cl.M-621210B%2Cl.M-62130A%2Cl.M-62130B%2C"; public static final String kronoxStringAgTodayAndTomorrow = "http://kronox-rapport.slu.se/setup/jsp/SchemaXML.jsp?startDatum=idag&intervallTyp=d&intervallAntal=2&sokMedAND=false&sprak=SV&resurser=l.M-620102%2Cl.M-620106%2Cl.M-620107%2Cl.M-620128%2Cl.M-620130%2Cl.M-620148%2Cl.M-620202%2Cl.M-620202A%2Cl.M-620212%2Cl.M-620222%2Cl.M-620223%2Cl.M-620224%2Cl.M-620224A%2Cl.M-620225%2Cl.M-620226%2Cl.M-621102%2Cl.M-621112%2Cl.M-621114%2Cl.M-621115%2Cl.M-621118%2Cl.M-621120%2Cl.M-621121A%2Cl.M-621121B%2Cl.M-621121C%2Cl.M-621207%2Cl.M-621208A%2Cl.M-621208B%2Cl.M-62120A%2Cl.M-62120B%2Cl.M-62120C%2Cl.M-621210A%2Cl.M-621210B%2Cl.M-62130A%2Cl.M-62130B%2C"; public static final String kronoxStringAgTodayMedForklaringar = "http://kronox-rapport.slu.se/setup/jsp/SchemaXML.jsp?startDatum=idag&intervallTyp=d&intervallAntal=2&forklaringar=true&sokMedAND=false&sprak=SV&resurser=l.M-620102%2Cl.M-620106%2Cl.M-620107%2Cl.M-620128%2Cl.M-620130%2Cl.M-620148%2Cl.M-620202%2Cl.M-620202A%2Cl.M-620212%2Cl.M-620222%2Cl.M-620223%2Cl.M-620224%2Cl.M-620224A%2Cl.M-620225%2Cl.M-620226%2Cl.M-621102%2Cl.M-621112%2Cl.M-621114%2Cl.M-621115%2Cl.M-621118%2Cl.M-621120%2Cl.M-621121A%2Cl.M-621121B%2Cl.M-621121C%2Cl.M-621207%2Cl.M-621208A%2Cl.M-621208B%2Cl.M-62120A%2Cl.M-62120B%2Cl.M-62120C%2Cl.M-621210A%2Cl.M-621210B%2Cl.M-62130A%2Cl.M-62130B%2C"; public static final String kronoxStringAgTodayAndTomorrowMedForklaringar = "http://kronox-rapport.slu.se/setup/jsp/SchemaXML.jsp?startDatum=idag&intervallTyp=d&intervallAntal=4&forklaringar=true&sokMedAND=false&sprak=SV&resurser=l.M-620102%2Cl.M-620106%2Cl.M-620107%2Cl.M-620128%2Cl.M-620130%2Cl.M-620148%2Cl.M-620202%2Cl.M-620202A%2Cl.M-620212%2Cl.M-620222%2Cl.M-620223%2Cl.M-620224%2Cl.M-620224A%2Cl.M-620225%2Cl.M-620226%2Cl.M-621102%2Cl.M-621112%2Cl.M-621114%2Cl.M-621115%2Cl.M-621118%2Cl.M-621120%2Cl.M-621121A%2Cl.M-621121B%2Cl.M-621121C%2Cl.M-621207%2Cl.M-621208A%2Cl.M-621208B%2Cl.M-62120A%2Cl.M-62120B%2Cl.M-62120C%2Cl.M-621210A%2Cl.M-621210B%2Cl.M-62130A%2Cl.M-62130B%2C"; public static final int SECONDS_BETWEEN_KRONOXPARSING = 180; // public static HashMap<String, String> resurser_signaturer = new HashMap<String, String>(); public static HashMap<String, String> utb_kursinstans_grupper = new HashMap<String, String>(); public static ArrayList<SchemaPost> bookingsList = new ArrayList<SchemaPost>(); public static int minutesBefore = 40; // Show these as green minutes before they start public static int minutesLate = 20; // Let the bookings be there for 20 more minutes after start for late arrives // (Not Me) Show as Yellow public static int maxNumberPosts = 24; public static boolean addOngoingCourses = true; }
b5ffd211188f4a2facfc8e54c8af1fc130788d2d
7b7efa1195604e75995fab164471cb63c06cdd36
/selenium/Activities/Activity11a.java
f06ba488903f31be19dac2ce21acd9aec00619ce
[]
no_license
Twinkle-kumari/FST-M1
7bda958f3dfe38863d97c621929b537fa150ffc0
32fdbf25d6418da71c599521b8379bb2a665d5ab
refs/heads/main
2023-05-09T15:17:58.925023
2021-06-04T13:36:14
2021-06-04T13:36:14
372,764,509
0
0
null
null
null
null
UTF-8
Java
false
false
714
java
package Examples; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class Activity11a { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("https://www.training-support.net/selenium/javascript-alerts"); driver.findElement(By.xpath("//*[@id=\"simple\"]")).click(); //switching focus to Alert window Alert simpleAlert = driver.switchTo().alert(); String alertText = simpleAlert.getText(); System.out.println("Alert text is: " +alertText); simpleAlert.accept(); driver.close(); } }
9ab0843a574de84cbcddfd883b3fadbc7e57becd
83c439bf68736a6fb331283397c559ba56b4d6b6
/Android/PreZenTainer/src/com/puregodic/android/prezentainer/DetailSettingActivity.java
aacfa142c807a1939b15bd21fd870fbd25f3c5c6
[]
no_license
5-SH/PREZENTAINER
03b61a8b94709fb1f993a37a88c3082d393b6f2f
0609e4c9fa8cc057da05bcca3c2d569d8b1051c4
refs/heads/master
2021-05-29T07:05:30.656733
2015-08-09T10:19:52
2015-08-09T10:19:52
null
0
0
null
null
null
null
UHC
Java
false
false
6,108
java
package com.puregodic.android.prezentainer; import java.util.ArrayList; import android.app.ActionBar.LayoutParams; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.LinearLayout; public class DetailSettingActivity extends AppCompatActivity { public static int incrementID = 0; public static ArrayList<String> timeInterval = new ArrayList<String>(); public static ArrayList<EditText> editTextArr = new ArrayList<EditText>(); public static final int REQUEST_DETAIL = 3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detailsetting); final EditText num = (EditText)findViewById(R.id.num); final LinearLayout list =(LinearLayout)findViewById(R.id.list); Button btn = (Button)findViewById(R.id.btn); Button btnResult = (Button)findViewById(R.id.btnResult); //동적으로 원하는 갯수 만큼 edit text를 생성하는 확인 버튼 btn.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //이전값 삭제 timeInterval.clear(); editTextArr.clear(); list.removeAllViews(); incrementID = 0; //edittext 몇개 생성할 것인지 입력한 숫자 처리 String inputNumString = num.getText().toString(); final int inputNum = Integer.valueOf(inputNumString); //프레젠테이션 수가 너무 많으면 다시 물음 if (inputNum >= 100) { AlertDialog.Builder alert_confirm = new AlertDialog.Builder(DetailSettingActivity.this); alert_confirm.setMessage("입력하신 갯수가 맞습니까?").setCancelable(false).setPositiveButton("확인", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // 'YES' -> 입력한대로 EditText 동적생성 for (int i = 0; i < inputNum; i++) { incrementID++; final EditText numAdd = new EditText(DetailSettingActivity.this); //edit text 설정 numAdd.setHint(incrementID + "번째 슬라이드"); numAdd.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); numAdd.setPadding(50, 10, 50, 10); numAdd.setBackgroundColor(Color.YELLOW); numAdd.setId(incrementID); numAdd.setInputType(0x00000002); //숫자키패드만 뜨도록 //edit text 뷰에 올리는 메소드 list.addView(numAdd, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); //list.addView(numAdd, i); editTextArr.add(numAdd); } } }).setNegativeButton("재입력", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // 'No' -> 재입력 return; } }); AlertDialog alert = alert_confirm.create(); alert.show(); } else { //edit Text 동적생성 (100개를 넘지 않는 경우) for (int i = 0; i < inputNum; i++) { incrementID++; final EditText numAdd = new EditText(DetailSettingActivity.this); //edit text 설정 numAdd.setHint(incrementID + "번째 슬라이드"); numAdd.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); numAdd.setPadding(50, 10, 50, 10); numAdd.setBackgroundColor(Color.YELLOW); numAdd.setId(incrementID); numAdd.setInputType(0x00000002); //숫자키패드만 뜨도록 //edit text 뷰에 올리는 메소드 list.addView(numAdd, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); //list.addView(numAdd, i); editTextArr.add(numAdd); } } } }); //최종 결정된 time interval들을 입력하는 최종확인 버튼 btnResult.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { for (int i = 0; i < editTextArr.size(); i++) { // 사용자가 입력한 슬라이드시간 timeInteval에 입력 timeInterval.add(editTextArr.get(i).getText().toString()); Log.i("timeInterval", "tI size : " + timeInterval.size() + " tIvalue : " + timeInterval.get(i)); } //Intent intent = new Intent(DetailSettingActivity.this, SettingActivity.class); Intent intent = new Intent(); intent.putStringArrayListExtra("timeInterval", timeInterval); setResult(REQUEST_DETAIL, intent); finish(); } }); } }
db4c9ec08fa889f53c6db79bbba669362cc2ff1b
9f7f51739dbddf02db6ad2d203c928479a0d5353
/course-api/src/main/java/com/sharat/springbootstarter/controller/TopicController.java
0a5d821906740c4bed97e8aaea5ae9416c563cd5
[ "Apache-2.0" ]
permissive
sinsharat/RestfulSpringBootProjects
7aeb9059ada131b7f9f4164f378380cbcb9709fc
420715c688d42d669410a9f5aea0431ef949a2f3
refs/heads/master
2022-08-27T13:16:54.008669
2022-08-11T18:40:48
2022-08-11T18:41:30
232,589,113
0
0
null
null
null
null
UTF-8
Java
false
false
1,420
java
package com.sharat.springbootstarter.controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.sharat.springbootstarter.info.Topic; import com.sharat.springbootstarter.service.TopicService; @RestController public class TopicController { @Autowired TopicService topicService; @RequestMapping(method = RequestMethod.GET, path = {"/topics"}) public List<Topic> getAllTopics() { return topicService.getAllTopics(); } @RequestMapping(method = RequestMethod.GET, path = {"/topics/{id}"}) public Topic getTopic(@PathVariable String id) { return topicService.getTopic(id); } @RequestMapping(method = RequestMethod.POST, path= {"/topics"}) public void addTopic(@RequestBody Topic topic) { topicService.addTopic(topic); } @RequestMapping(method = RequestMethod.PUT, path= {"/topics"}) public void modifyTopic (@RequestBody Topic topic) { topicService.modifyTopic(topic); } @RequestMapping(method = RequestMethod.DELETE, path= {"topics/{id}"}) public void deleteTopic(@PathVariable String id) { topicService.deleteTopic(id); } }